Skip to content

Extiri/cdmn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeMenu CLI (cdmn)

A powerful command-line interface for CodeMenu, allowing you to access and manage your code snippets from the terminal.

Features

  • Search & Filter: Search snippets by query, language, tag, or group
  • Multiple Output Formats: JSON, table, or raw code output for easy piping
  • Interactive TUI: Beautiful terminal user interface for browsing snippets
  • Configuration Management: Save API keys and settings for quick access
  • Pipeline-Ready: Designed for use in CI/CD pipelines and automation scripts

Installation

From Source

git clone https://github.com/extiri/cdmn.git
cd cdmn
go build -o cdmn
sudo mv cdmn /usr/local/bin/

Using Go Install

go install github.com/extiri/cdmn@latest

Prerequisites

  • CodeMenu API must be enabled in CodeMenu settings
  • By default, the API runs at http://127.0.0.1:1300/v1
  • If you've enabled key protection, you'll need your API key

Quick Start

1. Configure API Key (Optional)

If your CodeMenu instance requires an API key:

cdmn config set --api-key your-api-key-here

2. List All Snippets

cdmn snippets

3. Launch Interactive TUI

cdmn tui

Usage

Commands

cdmn snippets - List and search snippets

# List all snippets
cdmn snippets

# Search for snippets
cdmn snippets --query "function"

# Filter by language
cdmn snippets --language python

# Filter by tag ID
cdmn snippets --tag TAG-UUID-HERE

# Filter by group ID
cdmn snippets --group GROUP-UUID-HERE

# Combine filters
cdmn snippets --query "async" --language javascript

# Output as JSON
cdmn snippets --output json

# Output only code (for piping)
cdmn snippets --output code

cdmn get - Get a specific snippet

# Get snippet by ID (text format)
cdmn get SNIPPET-ID

# Get snippet by title using fuzzy search (text format)
cdmn get "part of the name"

# Get snippet as JSON
cdmn get SNIPPET-ID --output json

# Get only the code
cdmn get SNIPPET-ID --output code

cdmn tags - List all tags

# List tags as table
cdmn tags

# List tags as JSON
cdmn tags --output json

cdmn groups - List all groups

# List groups as table
cdmn groups

# List groups as JSON
cdmn groups --output json

cdmn tui - Launch interactive TUI

# Start the interactive interface
cdmn tui

TUI Controls:

  • ↑/↓ or j/k - Navigate snippets
  • / - Search snippets
  • Enter - View snippet details
  • Esc - Go back
  • q - Quit

cdmn config - Manage configuration

# Show current configuration
cdmn config show

# Set API key
cdmn config set --api-key YOUR_KEY

# Set custom base URL
cdmn config set --base-url http://localhost:8080/v1

# Set custom port
cdmn config set --port 8080

Global Flags

All commands support these flags:

  • --api-key - Override API key from config
  • --base-url - Override base URL from config
  • --config - Specify custom config file location

Configuration

Configuration is stored in ~/.config/cdmn/.cdmn.yaml by default.

Example configuration:

api_key: your-secret-key
base_url: http://127.0.0.1:1300/v1
port: 1300

You can also use environment variables:

export CDMN_API_KEY=your-secret-key
export CDMN_BASE_URL=http://127.0.0.1:1300/v1
export CDMN_PORT=1300

Pipeline Examples

Extract code from a specific snippet

# Save snippet code to file
cdmn get SNIPPET-ID --output code > script.sh
chmod +x script.sh
./script.sh

Find and use Python snippets

# Get all Python snippets and process them
cdmn snippets --language python --output json | jq -r '.[].code'

Search and copy to clipboard

# macOS
cdmn snippets --query "docker" --output code | head -n 1 | pbcopy

# Linux
cdmn snippets --query "docker" --output code | head -n 1 | xclip -selection clipboard

Output Formats

Table (default)

Human-readable table format, perfect for terminal viewing.

JSON

Machine-readable JSON output, ideal for processing with jq or other tools.

Code

Raw code output only, perfect for piping directly to files or other commands.

API Reference

This CLI uses the CodeMenu HTTP API. For more details, see:

Project Structure

cdmn/
├── cmd/              # CLI commands (cobra)
│   ├── root.go
│   ├── snippets.go
│   ├── get.go
│   ├── tags.go
│   ├── groups.go
│   ├── config.go
│   └── tui.go
├── internal/
│   ├── client/       # API client
│   ├── config/       # Configuration management
│   └── tui/          # Terminal UI (bubbletea)
├── main.go
├── go.mod
└── README.md

Dependencies

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Support

For issues and questions:

Author

Created for the CodeMenu ecosystem by Extiri.

About

CodeMenu CLI utility

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published