snipshare-cli
v0.0.4
Published
代码片段管理工具 - 个人自用 + 团队共享
Maintainers
Readme
snippet - Code Snippet Management Tool
A CLI tool for saving, managing, and sharing code snippets.
🚀 Features
✅ Local code snippet saving (auto-scanning directories, extracting dependencies)
✅ Interactive command-line interface
✅ Snippet search (by title, description, tags, framework, database)
✅ Snippet metadata management (title, description, tags)
✅ Project isolation (each project's snippets are saved independently)
✅ Automatic Token generation (automatically generated on first use, no manual configuration needed)
✅ Upload/Share snippets to server
✅ List snippets on server
✅ Delete snippets from server
✅ Download snippets from server
✅ Install snippets to current project
Contact me: [email protected]
Github: https://github.com/Wonkmy/snipshare-cli.git
📦 Installation
npm install -g snipshare-cli🛠️ Usage
First Use
After installation, run any command to automatically generate a Token:
snippet helloHelp
snippet --helpVersion
snippet -vConfiguration
View Current Configuration
snippet config getSet Configuration
snippet config set <key> <value>Supported configuration items:
server- Server address (default: none - you need to deploy your own server)token- Authentication Token (automatically generated on first use, no manual configuration needed)
Note: Token is automatically generated in ~/.snippet/config.json with format user_ + random string. A new Token is generated each time the tool is reinstalled.
Server Deployment Required: Remote features (publish, download, etc.) require a server. To use these features:
- Deploy your own server (see Server Deployment)
- Configure the client:
snippet config set server http://your-server:3000Reset Configuration: To reset all configuration to default values:
snippet config resetSave Code Snippet
snippet save <directory>Examples:
# Save snippets from current directory
snippet save .
# Save snippets from specific directory
snippet save ./my-projectAfter running, you will be prompted to enter:
- Snippet name (default is directory name)
- Description
- Framework (Express/NestJS/Koa/Fastify/Other)
- Database (MongoDB/MySQL/PostgreSQL/SQLite/No Database)
- Tags (comma-separated)
Saved content:
- All source code files (auto-scanned, node_modules folder is automatically ignored)
- Dependencies from package.json
- Snippet metadata (title, description, framework, database, tags)
Save location: current directory/snippets/
List All Snippets
snippet listDisplays basic information for all snippets:
- ID
- Name
- Description
- Framework and Database
- Tags
- Creation Time
- File Count
View Snippet Details
snippet view <id>Example:
snippet view mn76p6qcdckniDisplays detailed information including all files.
Update Snippet Metadata
snippet update <id>Example:
snippet update mn76p6qcdckniAfter running, you will be prompted to enter:
- New title (default is current title)
- New description (default is current description)
- New tags (default is current tags)
Delete Snippet
snippet delete <id>Example:
snippet delete mn76p6qcdckniSearch Snippets
snippet search <keyword>Examples:
# Search for snippets containing "express"
snippet search express
# Search for snippets containing "mongodb"
snippet search mongodb
# Search for snippets containing "authentication"
snippet search authenticationSearch scope:
- Title
- Description
- Tags
- Framework
- Database
Case-insensitive matching.
Upload Snippet to Server
snippet publishAfter running, it will:
- List all local snippets
- Select snippet to upload
- Display snippet details (name, description, framework, database, tags, file count, dependency count)
- Confirm upload
Upload requirements:
- Official address:
https://snipshare.dxstudio.site - Server address must be configured first:
snippet config set server <server address> - Token is automatically included in request headers (format:
Authorization: Bearer <token>)
List Server Snippets
snippet list-remoteDisplays basic information for all server snippets:
- ID
- Name
- Description
- Framework and Database
- Tags
- Creation Time
- File Count
Delete Server Snippet
snippet delete-remote <id>Example:
snippet delete-remote mn76p6qcdckniDownload Snippet from Server
snippet downloadAfter running, it will:
- List all server snippets
- Select snippet to download
- Prompt for save directory
List Downloaded Snippets
snippet list-downloadedInstall Snippet to Current Project
snippet install <id>After running, it will:
- Prompt for installation directory (default is current project)
Uninstall Snippet
snippet uninstall <id>Example:
snippet uninstall mn76p6qcdckni📝 Notes
- Snippets are saved in the
snippets/folder in the current working directory node_modulesfolder is automatically ignored- Snippet ID is an automatically generated unique identifier
updatedAttimestamp is automatically updated when snippet metadata is modified- Token is stored in
~/.snippet/config.jsonwith formatuser_+ random string - Reinstalling the tool generates a new Token (because
~/.snippetdirectory is deleted)
🖥️ Server Deployment
Deploy Official Server
The official server is hosted at https://snipshare.dxstudio.site. Remote features (publish, download, etc.) require a server.
To deploy your own server:
- Clone or copy the
snippet-serverfolder to your server - Install dependencies:
cd snippet-server
npm install- Create
.envfile:
cp .env.example .env- Edit
.env:
PORT=3000
DATA_DIR=./data- Start the server:
npm startYour server will be available at http://your-server:3000.
Configure Client
After deploying your server, configure the client:
snippet config set server http://your-server:3000✅ Completed Features
Phase 1: Local Management
- ✅ save command (save code snippet)
- ✅ list command (list all snippets)
- ✅ view command (view snippet details)
- ✅ update command (update snippet metadata)
- ✅ delete command (delete snippet)
- ✅ search command (search snippets)
Phase 2: Remote Management
- ✅ publish command (upload snippet to server)
- ✅ list-remote command (list server snippets)
- ✅ delete-remote command (delete server snippet)
- ✅ Automatic token generation
Phase 3: Download/Install
- ✅ download command (download snippet from server)
- ✅ install command (install snippet to current project)
- ✅ list-downloaded command (list downloaded snippets)
- ✅ uninstall command (uninstall snippet)
📄 License
MIT
