Skip to main content

lnkshrt-cli is a command-line interface (CLI) tool for interacting with the lnkshrt link shortening API. It provides a convenient way to manage and utilize the features of the lnkshrt API directly from the command line.

Project description

screenshot

lnkshrt-cli

lnkshrt-cli is a command-line application that allows you to easily generate shortened URLs, authenticate with your lnkshrt account, delete links, and perform other actions from the command line. It provides a convenient and efficient way of interfacing with the lnkshrt link shortening API hosted at lnkshrt.xyz

Table of Contents

Features

  • Generate shortened URLs for quick and easy sharing.
  • Delete existing links when they are no longer needed.
  • Easily authenticate with the API.
  • Generate QR codes for the shortened URLs.

By default, the CLI app interacts with the lnkshrt API instance hosted at lnkshrt.xyz. However, if you prefer to use a different lnkshrt API instance, you have the flexibility to set a custom instance using the lnkshrt config --instance-url command. This is particularly useful for development purposes.

For more information about the lnkshrt API itself, see the API repository.

Installation

You can install lnkshrt-cli using pip or pipx (recommended):

Installation with pip

pip install lnkshrt

Installation with pipx (recommended)

Alternatively, if you prefer to install the package in an isolated environment, use pipx:

pipx install lnkshrt

Quick Start

  1. Create an account:

    lnkshrt create --username <your_username> --email <valid_email>
    
  2. Once you have created an account, you can authenticate with lnkshrt-cli using the following command:

    lnkshrt login --username <your_username>
    

    This will prompt you to enter your lnkshrt account credentials and generate an authentication token for API access. The token will be saved and used for subsequent API requests.

  3. To generate a shortened URL:

    lnkshrt create <url you want to shorten>
    
  4. To delete a previously created link, you can use the lnkshrt delete command followed by the shortened URL:

    lnkshrt delete <short_url>
    

    Replace <short_url> with the shortened URL you intend to delete.

For more information on available commands and options, you can use the built-in help:

lnkshrt --help

Usage

$ lnkshrt [OPTIONS] COMMAND [ARGS]...

Options:

  • --install-completion: Install completion for the current shell.
  • --show-completion: Show completion for the current shell, to copy it or customize the installation.
  • --help: Show this message and exit.

Commands:

  • config: Configure lnkshrt settings.
  • create: Create a shortened URL.
  • delete: Delete a shortened URL.
  • login: Authenticate with an existing user account.
  • signup: Create a new user account.

lnkshrt config

Configure lnkshrt settings.

This command provides a convenient way to set and modify lnkshrt settings. The settings are stored in a configuration file named settings.toml. This command is the recommended way of modifying this file.

Usage:

$ lnkshrt config [OPTIONS]

Options:

  • --instance-url TEXT: The URL of the instance to use for shortening links.If invoked without any value, the instance URL will be reset to the default.
  • --token TEXT: Set the authentication token to be used for API access.
  • --help: Show this message and exit.

lnkshrt create

Create a shortened URL.

Usage:

$ lnkshrt create [OPTIONS] URL

Arguments:

  • URL: The original URL to be shortened. [required]

Options:

  • --custom-path TEXT: Specify a custom path for the shortened URL.
  • --generate-qr-code TEXT: If provided, generate a QR code for the shortened URLThe generated QR code image will be saved to the specified location.
  • --help: Show this message and exit.

lnkshrt delete

Delete a shortened URL.

Usage:

$ lnkshrt delete [OPTIONS] URL

Arguments:

  • URL: The original URL to be shortened. [required]

Options:

  • --help: Show this message and exit.

lnkshrt login

Authenticate with an existing user account.

Upon successful authentication, an authentication token will be generated and stored for future API requests. Accounts can be created using the lnkshrt signup command.

Usage:

$ lnkshrt login [OPTIONS]

Options:

  • --username TEXT: [required]
  • --password TEXT: Your password. If not provided, you will be prompted to enter it. [required]
  • --help: Show this message and exit.

lnkshrt signup

Create a new user account.

Usage:

$ lnkshrt signup [OPTIONS]

Options:

  • --username TEXT: [required]
  • --email TEXT: [required]
  • --password TEXT: Your password. If not provided, you will be prompted to enter it. [required]
  • --help: Show this message and exit.

Development

  • Clone the repository and navigate to the project directory:

    git clone https://github.com/vivekashok1221/lnkshrt-cli.git
    
    cd lnkshrt-cli
    
  • Set up poetry env

    Assuming you have poetry installed, install the dependencies by running:

    poetry install
    

    To activate the poetry venv:

    poetry shell
    
  • Set Up Pre-commit Hooks

    poetry run task precommit
    

    pre-commit helps ensure code quality and consistency by automatically running various checks and formatting tools on your code before each commit.

  • Linting

    To manually run the linting checks:

    poetry run task lint
    
  • If you want to use a locally running instance of the API:

    1. Set up lnkshrt API by following the guide in the "Getting Started" section of the API repository.

    2. Set the instance URL to http://0.0.0.0:8000 by running the following command:

      lnkshrt config --instance-url http://0.0.0.0:8000
      

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lnkshrt_cli-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lnkshrt_cli-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file lnkshrt_cli-0.1.0.tar.gz.

File metadata

  • Download URL: lnkshrt_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.4.3-arch1-1

File hashes

Hashes for lnkshrt_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 780ed6237486b16bc7075b7e9484cd6aab3ed146b98e6da5cb159d0fc35b5cb6
MD5 49207c9d51eec46bf927e64043e51a36
BLAKE2b-256 716a6987495193c1fa2ff9f135c5d485408ff1687dcb6ce44dcf47ede2d77606

See more details on using hashes here.

File details

Details for the file lnkshrt_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lnkshrt_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.4.3-arch1-1

File hashes

Hashes for lnkshrt_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e91025020a1a77b5f7ce299f9c22e7c3dfa6361cd357435bbc2b440a246438ca
MD5 b17492a370854b916c7dd9d090b35324
BLAKE2b-256 daa28f362f0338b7e6c12974e310e0b1e8bce0aaddefaf417156176cda9016f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page