๐ฆ SNIP - Code Snippet Manager
A beautiful terminal-based code snippet manager built with Go and Bubble Tea

โจ Features
- ๐จ Beautiful TUI - Interactive terminal interface with tabbed navigation
- ๐ Category Management - Organize snippets into logical categories
- ๐ท๏ธ Tag System - Multi-tag support for flexible organization
- ๐ Full-Text Search - Quickly find snippets by title, description, or code
- โจ๏ธ Syntax Highlighting - Code editor with line numbers
- ๐ Dual Interface - Use interactive TUI or traditional CLI commands
๐ธ Screenshots
Interactive TUI Mode
โญโโโโโโโโโโโโโโโโโโโโโฎโญโโโโโโโโโโโโโโโโโโโโโฎโญโโโโโโโโโโโโโโโโโโโโโฎโญโโโโโโโโโโโโโโโโโโโโโฎ
โ โจ Home โโ Categories โโ Tags โโ Snippets โ
โ โโดโโโโโโโโโโโโโโโโโโโโโดโดโโโโโโโโโโโโโโโโโโโโโดโดโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโ โ
โ โโ โโ โ
โ โโ โโ โโ โโ โ
โ โโ โโ โโ โโ โ
โ โโ โโ โ
โ โโ โโโโโโโโ โโ โ
โ โโโโ โโโโ โ
โ โ
โ SNIP - Code Snippet Manager โ
โ โ
โ Welcome! Use the tabs above to navigate: โ
โ - Home - You are here โ
โ - Categories - Manage snippet categories โ
โ - Tags - Manage snippet tags โ
โ - Snippets - Manage code snippets โ
โ โ
โ Navigation: โ
โ Ctrl+F - Toggle between Interactive and Navigation mode โ
โ Tab - Next tab (in Navigation mode) โ
โ Shift+Tab - Previous tab (in Navigation mode) โ
โ โ/โ - Switch tabs (in Navigation mode) โ
โ PgUp/PgDn - Scroll content (in Interactive mode) โ
โ Ctrl+โ/โ - Scroll horizontally โ
โ Ctrl+C - Quit โ
โ โ
โ Mode Indicators: โ
โ โจ (green) - Interactive mode: Components receive keyboard input โ
โ โ (blue) - Navigation mode: Tab switching and scrolling enabled โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Ctrl+F: toggle mode | Ctrl+C: quit
๐ Quick Start
Installation
Download Pre-built Binary
Download the latest release for your platform from the releases page.
Linux/macOS:
# Download and install (replace VERSION with actual version)
curl -L https://github.com/7-Dany/snip/releases/download/vVERSION/snip-linux-amd64 -o snip
chmod +x snip
sudo mv snip /usr/local/bin/
Windows (PowerShell):
# Download from releases page and add to PATH
Build from Source
# Clone the repository
git clone https://github.com/7-Dany/snip.git
cd snip
# Build and install
make build
sudo make install
# Or use go install
go install
First Run
# Launch interactive TUI
snip
# Or use CLI commands, note: to work with commands snip must be followed with arguments.
snip snippet create
snip snippet list
snip help
๐ Usage
Interactive TUI Mode
The recommended way to use SNIP is through the interactive TUI:
snip
Keyboard Shortcuts:
| Key |
Action |
Ctrl+F |
Toggle between Interactive and Navigation mode |
Tab / Shift+Tab |
Navigate between tabs (Navigation mode) |
โ / โ |
Switch tabs (Navigation mode) |
โ / โ |
Navigate lists/menus |
Enter |
Select item / Confirm action |
/ |
Start search/filter |
a |
Add new item |
r |
Refresh list |
? |
Show help |
Esc |
Cancel / Go back |
Ctrl+C |
Quit application |
In Code Editor:
| Key |
Action |
Tab / Shift+Tab |
Navigate between fields |
Alt+C |
Select category |
Alt+T |
Manage tags |
Ctrl+S |
Save snippet |
Esc |
Cancel editing |
CLI Commands
Snippet Management
# Create a new snippet interactively
snip snippet create
# List all snippets
snip snippet list
# List snippets with filters
snip snippet list --language go
snip snippet list --category 1
snip snippet list --tag 2
# Show a specific snippet
snip snippet show 5
# Update a snippet
snip snippet update 5
# Delete a snippet
snip snippet delete 5
# Search snippets
snip snippet search "binary tree"
Category Management
# Create a category
snip category create algorithms
snip category create # Interactive mode
# List all categories
snip category list
# Delete a category
snip category delete 3
Tag Management
# Create a tag
snip tag create performance
snip tag create # Interactive mode
# List all tags
snip tag list
# Delete a tag
snip tag delete 7
Help
# General help
snip help
# Topic-specific help
snip help snippet
snip help category
snip help tag
๐๏ธ Architecture
snip/
โโโ cmd/ # Application entry points
โ โโโ main.go # Main CLI application
โโโ internal/
โ โโโ cli/ # CLI layer
โ โ โโโ commands/ # CLI command handlers
โ โ โโโ components/ # Reusable Bubble Tea UI components
โ โ โโโ tui/ # Terminal UI implementation
โ โโโ domain/ # Business logic and entities
โ โโโ storage/ # Data persistence layer
โโโ main.go
Key Components
- Domain Layer: Pure business logic (snippets, categories, tags)
- Storage Layer: JSON-based repositories with transaction support
- CLI Commands: Traditional command-line interface
- TUI: Interactive terminal interface using Bubble Tea
- Components: Reusable UI widgets (tables, editors, menus, dialogs)
๐งช Testing
Test Coverage
SNIP maintains comprehensive test coverage across its core components:
| Component |
Coverage |
Notes |
| Domain Layer |
~100.0% |
Business logic fully tested |
| Storage Layer |
~99.5% |
Repository operations and transactions |
| CLI Commands |
~85% |
Command handlers and validation |
| Overall |
~85% |
Excluding interactive TUI components |
# Run all tests
make test
# Run tests with coverage report
go test ./... -cover
# Generate detailed coverage report
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
Testing Approach
โ
What We Test
- Business Logic: All domain entities, validation rules, and state management
- Data Persistence: Repository CRUD operations, queries, and transactions
- CLI Commands: Command parsing, argument validation, and error handling
- Error Paths: Database errors, invalid input, and edge cases
โ ๏ธ What We Don't Test (And Why)
Interactive TUI Components are intentionally excluded from automated testing for the following reasons:
- Framework Limitations: Bubble Tea's event-driven architecture and terminal rendering make unit testing impractical without extensive mocking
- Testing Complexity: UI interactions involve complex state machines, terminal dimensions, and timing-dependent updates that are difficult to reproduce in tests
- Visual Nature: TUI correctness is inherently visual - automated tests can't validate layout, colors, or user experience
- Rapid UI Changes: UI/UX iterations are frequent and would require constant test maintenance
- Manual QA is More Effective: Interactive components are better validated through:
- Manual testing during development
- Smoke tests before releases
- User feedback and bug reports
User Input Prompts (like delete confirmations) are also not fully tested because:
- They rely on
fmt.Scanln() which reads from stdin
- Mocking stdin in Go tests is complex and fragile
- These are simple UI flows with minimal business logic
- Refactoring for testability would add unnecessary complexity
๐ฏ Testing Strategy
Our testing strategy focuses on:
- High-value tests: Core business logic and data integrity
- Fast feedback: Unit tests run in milliseconds
- Maintainability: Tests are simple and don't require complex mocks
- Confidence: Critical paths have multiple test scenarios
The combination of automated tests for logic layers and manual testing for UI provides the best balance of confidence and development velocity.
Running Tests
# Run all tests
go test ./...
# Run tests with verbose output
go test -v ./...
# Run tests for specific package
go test ./internal/domain/...
go test ./internal/storage/...
go test ./internal/cli/commands/...
# Run tests with race detection
go test -race ./...
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
# View coverage in browser
go tool cover -html=coverage.out
Test Organization
internal/
โโโ domain/
โ โโโ snippet_test.go # Domain entity tests
โ โโโ category_test.go
โ โโโ tag_test.go
โโโ storage/
โ โโโ snippet_repo_test.go # Repository tests
โ โโโ category_repo_test.go
โ โโโ tag_repo_test.go
โโโ cli/
โโโ commands/
โโโ snippet_test.go # CLI command tests
โโโ category_test.go
โโโ tag_test.go
๐ ๏ธ Development
Prerequisites
Building
# Build for current platform
make build
# Build for all platforms
make build-all
# Run tests
make test
# Clean build artifacts
make clean
Development Workflow
- Make your changes
- Run tests:
make test
- Check coverage:
go test -cover ./...
- Test manually with:
go run main.go
- Build:
make build
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Contribution Guidelines
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Write tests for new functionality (where applicable)
- Ensure all tests pass (
go test ./...)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
What to Test
- โ
Do add tests for: Domain logic, repository operations, CLI command handlers
- โ ๏ธ Optional for: TUI components (manual testing is acceptable)
- โ
Always test: Error handling and edge cases
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Bubble Tea - amazing TUI framework
- Uses Lipgloss for styling
- Inspired by the need for a simple, elegant snippet manager
โญ If you find this project useful, please consider giving it a star!