Skip to content

stevengregory/musing-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Musing CLI

A fast command-line tool for managing multi-service development stacks with Docker, MongoDB, and microservices.

What Does It Do?

This CLI provides professional tooling for complex development environments:

  • Live monitoring dashboard - Real-time health checks for all services (3-second refresh)
  • Docker stack management - Start/stop/rebuild services with auto-detection
  • Safe deployments - MongoDB data sync with confirmations and tunnel verification
  • Beautiful TUI - Professional terminal UI powered by Charm Bracelet

My Workflow

This is my DevOps command center for stevengregory.io. A tool managing my full-stack application: Angular frontend, Go service layer, and MongoDB database. Built for speedy local development and deployment of decoupled, multi-service stacks.

Prerequisites

  • Docker Desktop (for dev command)
  • mongoimport (for deploy command; available via MongoDB Database Tools)
  • SSH + lsof (for tunnel/ssh commands)
  • Docker Compose (for service orchestration)

Installation

Homebrew

brew tap stevengregory/musing
brew install musing

Tap repository: stevengregory/homebrew-musing

Upgrading:

brew update && brew upgrade musing

Commands

monitor

Live dashboard with real-time health checks.

musing monitor

Features:

  • Real-time service health monitoring (3-second refresh)
  • Color-coded status indicators for each service
  • Organized sections: Docker → Database → API Services → Frontend → SSH Tunnels
  • Keyboard controls: q, Ctrl+C, or Esc to exit

dev

Manage the development stack.

musing dev           # Start all services
musing dev start     # Start all services (explicit)
musing dev stop      # Stop all services
musing dev rebuild   # Rebuild images and start
musing dev logs      # Follow logs

Features:

  • Auto-detects and starts Docker Desktop if needed
  • Validates required repositories exist
  • Health checks for MongoDB and frontend
  • Progress indicators for long operations

tunnel

Manage SSH tunnel to production database.

musing tunnel         # Start tunnel (or show status if running)
musing tunnel start   # Start tunnel explicitly
musing tunnel stop    # Stop tunnel
musing tunnel status  # Check tunnel status

Features:

  • Auto-configures from .musing.yaml production settings
  • Supports custom SSH key paths with ~ expansion
  • Checks if tunnel is already running
  • Automatically backgrounds SSH process
  • Auto-managed by deploy command for production deployments

ssh

Open an interactive SSH session to your production server.

musing ssh

Features:

  • Auto-configures from .musing.yaml production settings
  • Supports custom SSH key paths with ~ expansion
  • Interactive shell session for debugging and administration

deploy

Deploy MongoDB collections to dev or production.

musing deploy              # All collections to dev
musing deploy news         # Deploy news to dev
musing deploy news prod    # Deploy news to prod

How it works:

  • Auto-discovers all .json files in your data directory
  • Collection names derived from filenames (e.g., news.jsonnews collection)
  • Automatically detects JSON arrays vs. objects
  • No manual configuration needed

Production safety:

  • Interactive confirmation required
  • Auto-opens SSH tunnel if not already running
  • Auto-closes tunnel after deployment completes
  • Clear warnings about data overwrite

version

Check the installed version.

musing version
musing --version

Configuration

Create a .musing.yaml file in your project root to define your stack:

services:
  # Frontend
  - name: Angular
    port: 3000
    type: frontend

  # API Services
  - name: my-api
    port: 8080
    type: api

# Database configuration
database:
  type: MongoDB
  name: mydb
  devPort: 27018
  prodPort: 27019
  dataDir: data

# Optional: Production deployment settings
production:
  server: root@your-server.com # SSH server for production access
  remoteDBPort: 27017 # Remote database port (typically 27017 for MongoDB)
  sshKeyPath: ~/.ssh/your-key # Optional: specific SSH key to use (supports ~ expansion)

Why This Approach?

Project-agnostic design means you can adapt it for any stack:

  • Works with any frontend framework (Angular, React, Vue, etc.)
  • Backend-agnostic (Go, Node, Python microservices)
  • Service configurations in internal/config/config.go
  • Docker Compose integration
  • Port-based health checking (framework-independent)
  • MongoDB deployment patterns
  • SSH tunnel support for remote databases

Key benefits:

  • Fast startup (1-3ms)
  • Type-safe Go prevents runtime errors
  • Professional terminal UI with Bubble Tea
  • Single binary with zero dependencies

Development

# Run without installing
go run ./cmd/musing monitor
go run ./cmd/musing dev

# Build for development (with version detection)
make build

# Manage dependencies
go mod tidy

Architecture

musing-cli/
├── cmd/
│   ├── musing/
│   │   └── main.go     # Entry point
│   ├── dev.go          # Dev command
│   ├── deploy.go       # Deploy command
│   ├── monitor.go      # Monitor command
│   ├── ssh.go          # SSH command
│   ├── tunnel.go       # Tunnel command
│   ├── project.go      # Shared project/config loading helpers
│   └── root.go         # Root command setup
├── internal/
│   ├── config/         # Service configs & ports
│   ├── docker/         # Docker operations
│   ├── health/         # Health checks
│   ├── mongo/          # MongoDB deployment
│   └── ui/             # Styled output & prompts

Tech Stack:

  • Go (fast, type-safe, single binary)
  • Bubble Tea (interactive TUI)
  • Lip Gloss (terminal styling)
  • Huh (confirmation prompts)

See CLAUDE.md for detailed architecture and development guidelines.

Screenshots

Help Command (click to expand)

Musing CLI Help

Monitor Command (click to expand)

Musing Monitor

License

MIT

About

CLI for managing microservice stacks with Docker and MongoDB

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors