codetainer
Version:
A clean and simple CLI to manage and store code snippets with ease.
157 lines (97 loc) โข 2.73 kB
Markdown



## ๐ฆ Codetainer
A clean and simple CLI to manage and store your favorite code snippets like a dev wizard ๐งโโ๏ธ. Save, tag, search, export, and edit snippets with blazing speed from your terminal.
### ๐ Installation
```bash
npm install -g codetainer
```
> Make sure your `package.json` has:
>
> ```json
> "bin": {
> "ctn": "./bin/index.js"
> }
> ```
### ๐ Usage
```bash
ctn [command] [...options]
```
### โจ Commands
#### `ctn add`
Create a new snippet interactively.
#### `ctn list`
List all saved snippets.
#### `ctn get <name>`
Show snippet content.
#### `ctn search <query>`
Search snippets by name, tag, or code content.
#### `ctn copy <name>`
Copy snippet code to clipboard.
#### `ctn delete <name>`
Delete a snippet.
#### `ctn tag <name> [tags...]`
Add one or more tags to a snippet.
#### `ctn edit <name> [options]`
Edit a snippet.
Options:
- `-c, --code` Edit code in an editor
- `-l, --language <language>` Change language
- `-t, --tags <tags...>` Replace tags
#### `ctn rename <oldName> <newName>`
Rename a snippet.
#### `ctn export <name>`
Export a snippet as a code file.
#### `ctn export-all [--language <lang>]`
Export all snippets to files. Filter by language if needed.
#### `ctn import-file <file> [--name <name>] [--tags <tags>]`
Import a file as a snippet.
#### `ctn watch <name>`
Edit and live-save a snippet in your default editor (like VS Code).
### ๐ง Examples
```bash
ctn add
ctn tag my-snippet utils express
ctn search express
ctn edit my-snippet -c
ctn export my-snippet
ctn import-file ./cool.js -n my-cool-snippet -t js,api
```
### ๐๏ธ Snippet Format
Snippets are stored as JSON like:
```json
{
"my-snippet": {
"code": "console.log('Hello')",
"language": "javascript",
"tags": ["console", "log"]
}
}
```
Stored at: `~/.codetainer/snippets.json`
### ๐ Dev Setup
To develop locally:
```bash
git clone https://github.com/yourusername/codetainer
cd codetainer
npm install
npm link # so you can run `ctn` globally
```
### ๐งช TODO Ideas
- [ ] Fuzzy search with better CLI UI
- [ ] GitHub Gist import/export
- [ ] Snippet sharing
- [ ] Categorize by project or language
[](./docs/USAGE.md)
### ๐ License
MIT ยฉ Joseph Agbonifo