shortenit-cli
v1.1.5
Published
CLI tool for Shortenit URL shortener
Maintainers
Readme
Shortenit CLI
A command-line interface tool for the Shortenit URL shortener service. Create shortened URLs, expand them back to original URLs, and generate QR codes - all from your terminal.
Features
- Shorten URLs - Create shortened links with optional custom aliases
- Expand URLs - Retrieve original URLs from shortened links
- Edit URLs - Update title, alias, expiration, or status of shortened links
- Delete URLs - Delete shortened links
- List URLs - List shortened links
- Expiration Control - Set custom expiration periods for your links
- QR Code Generation - Generate QR codes in terminal or save as PNG files
- Configuration Management - Easy setup and configuration management
- Beautiful CLI - Colored output and loading indicators for better UX
Installation
From NPM
npm install -g shortenit-cliFrom Source
# Clone the repository
git clone https://github.com/shortenit/shortenit-cli
cd shortenit-cli
# Install dependencies
npm install
# Build the project
npm run build
# Link globally (optional)
npm linkConfiguration
On first run, the CLI will prompt you to configure your backend URL and API Key:
shortenitOr manually configure:
shortenit configConfiguration Commands
shortenit config- Setup or update configurationshortenit config --show- Display current configurationshortenit config --reset- Reset configuration
The configuration is stored locally using conf and persists between sessions.
Usage
Shorten a URL
Basic usage:
shortenit short https://example.com/very/long/urlWith custom alias:
shortenit short https://example.com --custom-alias my-linkWith expiration (in days):
shortenit short https://example.com --expiration-days 7Generate QR code in terminal:
shortenit short https://example.com --print-qrSave QR code to Downloads folder:
shortenit short https://example.com --save-qrCombine multiple options:
shortenit short https://example.com \
--custom-alias my-link \
--expiration-days 30 \
--print-qr \
--save-qrExpand a URL
Retrieve the original URL from a shortened link:
shortenit expand abc123Or with full URL:
shortenit expand https://short.link/abc123Delete a URL
Basic usage:
shortenit delete abc123Or with full URL:
shortenit delete https://short.link/abc123Delete without confirmation:
shortenit delete https://short.link/abc123 --forceEdit a URL
Update the title:
shortenit edit abc123 --title "New Title"Change the custom alias:
shortenit edit abc123 --custom-alias newcodeUpdate expiration:
shortenit edit abc123 --expiration-days 30Remove expiration:
shortenit edit abc123 --clear-expirationDeactivate a link:
shortenit edit abc123 --inactiveReactivate a link:
shortenit edit abc123 --activeCombine multiple updates:
shortenit edit abc123 --title "Updated Title" --expiration-days 60 --activeList recent links
Display the most 10 recent shortened links:
shortenit listList all links
Display all the shortened links:
shortenit list-allHelp
View all available commands:
shortenit --helpView help for a specific command:
shortenit short --help
shortenit expand --helpCommands Reference
short <url>
Create a shortened link.
Options:
-c, --custom-alias <string>- Custom alias for the short URL-e, --expiration-days <number>- Number of days until expiration-p, --print-qr- Print QR code to terminal-s, --save-qr- Save QR code to Downloads folder
expand <url>
Get the original URL from a shortened link.
delete <url>
Delete a shortened link.
Options:
-f, --force- Force deletion without confirmation
edit <url>
Edit a shortened link.
Options:
-t, --title <string>- Update the title-c, --custom-alias <string>- Update the custom alias-e, --expiration-days <number>- Update expiration days--clear-expiration- Remove expiration date--active- Set link as active--inactive- Set link as inactive
list
List 10 recent shortened links.
list-all
List all shortened links.
config
Manage configuration settings.
Options:
--reset- Reset configuration--show- Show current configuration
Development
Project Structure
shortenit-cli/
├── src/
│ ├── index.ts # Main entry point
│ ├── commands/
│ │ ├── ShortCommand.ts # URL shortening command
│ │ ├── ExpandCommand.ts # URL expansion command
│ │ ├── EditCommand.ts # URL editing command
│ │ ├── DeleteCommand.ts # URL deletion command
│ │ └── ListCommand.ts # URL listing command
│ ├── config/
│ │ └── ConfigManager.ts # Configuration management
│ └── services/
│ ├── ApiService.ts # API communication
│ └── QRCodeService.ts # QR code generation
├── package.json
├── tsconfig.json
└── README.mdScripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Run in development mode with ts-nodenpm start- Run the compiled JavaScript
Dependencies
Runtime:
commander- CLI frameworkaxios- HTTP client for API callschalk- Terminal string stylinginquirer- Interactive command-line promptsora- Terminal spinnersqrcode- QR code generationqrcode-terminal- QR code display in terminalconf- Configuration managementtable- Table formatting for displaying URL lists
Development:
typescript- TypeScript compiler@types/node- Node.js type definitions@types/qrcode- QRCode type definitions@types/qrcode-terminal- QRCode Terminal type definitions
License
MIT
Contributors
Made with ❤️ for the Shortenit project
