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
- 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.
You can install lnkshrt-cli
using pip or pipx (recommended):
pip install lnkshrt
Alternatively, if you prefer to install the package in an isolated environment, use pipx:
pipx install lnkshrt
-
Create an account:
lnkshrt create --username <your_username> --email <valid_email>
-
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.
-
To generate a shortened URL:
lnkshrt create <url you want to shorten>
-
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
$ 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.
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.
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.
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.
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.
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.
-
git clone https://github.com/vivekashok1221/lnkshrt-cli.git cd lnkshrt-cli
-
Assuming you have poetry installed, install the dependencies by running:
poetry install
To activate the poetry venv:
poetry shell
-
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. -
To manually run the linting checks:
poetry run task lint
-
-
Set up
lnkshrt
API by following the guide in the "Getting Started" section of the API repository. -
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
-
This project is licensed under the MIT License.