pastedb-cli
v0.2.0
Published
Official CLI for PasteDB
Maintainers
Readme
PasteDB CLI
A fast, lightweight, and modern command-line interface for PasteDB — create, read, update, delete, explore, and manage your pastes directly from your terminal.
✨ Features
- 📤 Create pastes instantly from local files.
- 📋 Fetch and read existing pastes in your terminal.
- 🗑️ Delete pastes directly from the command line.
- 🌎 Explore public pastes without opening a browser.
- 👤 Manage your account status and user details.
- 🔑 Provision API keys dynamically.
- ▶️ Execute code through PasteDB's remote run service.
- 🔍 Validate custom IDs for availability instantly.
- 🗂️ Manage and browse your pastes interactively from the terminal
📦 Installation
Ensure you have Node.js 18+ installed on your system.
npm install -g pastedb-cliVerify that the installation was successful:
pdb --version🔐 Authentication
Before using API-dependent features, authenticate your terminal client.
pdb authYou will see the following interactive prompt:
PasteDB CLI Authentication
--------------------------
PasteDB API key: Once entered, your configuration updates:
✓ API key saved. You can now use PasteDB CLI commands.Storage and Environment Variables
- Local Storage: Your token resides locally at ~/.pastedb/config.json.
- Environment Overrides: You can export your key directly to your environment:
🚀 Commands
📤 Create a Paste
Upload a local file to PasteDB. The language syntax is automatically detected via the file extension.
pdb create app.pyOutput:
Uploading app.py...
✓ Paste created! https://pastedb.netlify.app/paste/abc123🧭 Interactive Create
Don't want to specify a file directly? Just run:
pdb createPasteDB opens an interactive creation flow:
What do you want to upload?
❯ File
Raw text
First item from clipboard📁 File
Choose File to upload a local file (Enter File name).
? Which file do you want to upload?
❯ app.py📝 Raw Text
Choose Raw text when you want to create a paste directly from text entered in the terminal.
? Enter your raw text:Enter your content and press Ctrl+D when you're finished.
📋 Clipboard
Selects First item from clipboard to upload the current clipboard content.
Before uploading, PasteDB shows you exactly what will be uploaded:
Clipboard content:
Example
------------------------------
print("Hello from PasteDB!")
------------------------------Press Ctrl+D to upload this content.
Supported syntax extensions include: .js, .py, .html, .css, .json, .md, .java, .cpp, .c, .go, .rs, .php, .rb, .sh, .sql, .xml, .yaml.
📥 Get a Paste
Print the raw contents of a specific paste directly to stdout.
pdb get abc123🗂️ Manage Pastes Interactively
Manage your PasteDB pastes directly from your terminal with the interactive paste manager.
pdb pastesThe interactive interface lets you:
📋 Browse all your pastes.
⬆️⬇️ Navigate between pastes using the arrow keys.
🌐 Open the selected paste directly in your browser.
🗑️ Delete pastes without leaving the terminal.
🔄 Refresh your paste list.
🔐 Recognizes encrypted/private pastes without displaying their encrypted content.
Controls
↑ ↓ Navigate between pastes
Enter Open the selected paste
d Delete the selected paste
r Refresh the paste list
q Quit
Ctrl+C ExitExample of pdb pastes:
╭──────────────────────────────────────────────────────────────╮
│ PasteDB │
│ Your Pastes │
╰──────────────────────────────────────────────────────────────╯
12 pastes
❯ app.py
ID: abc123
Language: python
Preview: print("Hello from PasteDB!")
website.html
ID: xyz789
Language: html
Preview: <!DOCTYPE html>...
[Encrypted paste]
ID: private123
Language: text
Preview: [Encrypted content]
──────────────────────────────────────────────────────────────
↑ ↓ Navigate O Open d Delete r Refresh q QuitThis provides a convenient way to manage your pastes without opening the PasteDB website.
✏️ Update a Paste
Overwrite an existing paste's content, language settings, and title with a local file.
pdb update abc123 app.pyNote: In the example, the abc123 is the pasteID which is to be updated and app.py is the file whose content will be replaced from the abc123.
🗑️ Delete a Paste
Remove a paste permanently from the server.
pdb delete abc123Output:
Deleting abc123...
✓ Paste deleted.🌎 Explore Public Pastes
Browse through trending and public feeds natively inside your terminal window.
pdb explore👤 Account Details
Check your active profile data and current PasteDB user statistics.
pdb me▶️ Run Code
Execute code snippets using PasteDB's remote code runtime engine.
pdb run <language> <file>Examples:
pdb run python app.py
pdb run javascript app.js🔍 Check Custom ID Availability
Verify if a specific vanity path string is available before publishing.
pdb check-id my-project🔑 Manage API Keys
Create, audit, and revoke access keys for other environments.
pdb key create "my-laptop" # Create a key
pdb key list # List active keys
pdb key delete # Delete a key
📋 Quick Reference
| Command | Description | |---|---| | pdb auth | Authenticate the CLI with an API key | | pdb create | Create a new paste from a file | | pdb get | Fetch and display a paste | | pdb update | Update an existing paste | | pdb delete | Delete a paste permanently | | pdb explore | View public pastes | | pdb me | View profile and account info | | pdb run | Remotely execute code | | pdb check-id | Check if a custom ID is free | | pdb key create | Generate a new API credential | | pdb key list | Review all connected keys | | pdb key delete | Revoke an API token | | pdb help / -h | Show global help instructions | | pdb pastes | Interactively browse, open, refresh, and delete your pastes |
🔒 Security
- Local credentials are saved with restricted file system permissions.
- The local config path is locked to ~/.pastedb/config.json.
- Important: Never commit your configuration directory or paste raw credentials into public repositories.
🛠️ Development
Get involved with development or build the package from source:
- Clone the repository:
git clone https://github.com/sorathiya903/pastedb-cli.git- Navigate to the project root:
cd pastedb-cli- Install the dependencies(if added in future):
npm install- Run the CLI tool locally:
node main.js