| Crates.io | trop-cli |
| lib.rs | trop-cli |
| version | 0.1.0 |
| created_at | 2025-10-21 03:32:39.363058+00 |
| updated_at | 2025-10-21 03:32:39.363058+00 |
| description | CLI tool for managing ephemeral port reservations |
| homepage | |
| repository | https://github.com/prb/trop |
| max_upload_size | |
| id | 1893240 |
| size | 576,232 |
Command-line interface for trop, a lightweight port reservation management tool for concurrent development workflows.
trop helps prevent port collisions when running multiple development servers, test suites, or other services that need to bind to network ports. It provides idempotent, directory-based port reservations that work across multiple processes and concurrent agents.
Early Development - Phase 1 Complete
Currently, the CLI only provides version and help output. Full functionality is under active development.
Phase 1 accomplishments:
Coming in Phase 2:
This is currently the only installation method:
# Clone the repository
git clone https://github.com/prb/trop.git
cd trop
# Build in release mode
cargo build --release
# The binary will be at: target/release/trop
Optionally, copy to a directory in your PATH:
cp target/release/trop ~/.local/bin/ # or /usr/local/bin/, etc.
Once published (not yet available):
cargo install trop-cli
Currently available commands:
# Show version
trop --version
# Show help
trop --help
Once fully implemented, typical workflows will include:
Reserve a port for the current directory:
port=$(trop reserve)
echo "Using port: $port"
Reserve multiple ports for the same directory:
web_port=$(trop reserve --tag web)
api_port=$(trop reserve --tag api)
db_port=$(trop reserve --tag db)
Example justfile:
port := `trop reserve`
dev:
npm run dev -- --port {{port}}
test:
npm test -- --port {{port}}
Reserve multiple ports at once from a trop.yaml file:
# Create trop.yaml with port definitions
trop reserve-group ./trop.yaml
# Or auto-discover trop.yaml
trop autoreserve
trop will support hierarchical configuration:
trop.local.yaml (project-specific, not in source control)trop.yaml (project config, checked into source control)~/.trop/config.yaml (user-level defaults)project: my-app
ports:
min: 5000
max: 7000
excluded_ports:
- 5432 # PostgreSQL default
reservations:
base: 5000
services:
web:
offset: 0
env: WEB_PORT
api:
offset: 1
env: API_PORT
See the implementation specification for complete configuration details.
Key environment variables (planned):
TROP_DATA_DIR: Override data directory location (default: ~/.trop)TROP_LOG_MODE: Control logging verbosity (quiet, normal, verbose)TROP_PROJECT: Set project identifierTROP_DISABLE_AUTOINIT: Disable automatic database initializationtrop reserve - Reserve a port for current directorytrop release - Release a reservationtrop list - List all active reservationstrop reserve-group - Reserve multiple ports from configtrop autoreserve - Auto-discover and reserve port grouptrop port-info <port> - Show reservation info for a porttrop assert-reservation - Check if reservation exists (exit code 0/1)trop assert-port <port> - Check if port is reserved (exit code 0/1)trop list-projects - List all active projectstrop prune - Remove reservations for deleted directoriestrop expire - Remove stale reservationstrop autoclean - Combined prune and expiretrop migrate - Move reservations between pathstrop init - Initialize data directory and configtrop validate <config> - Validate a trop.yaml filetrop scan - Scan for occupied portstrop exclude <port> - Add port to exclusion listtrop show-data-dir - Print data directory pathtrop show-path - Print resolved path for reservation0 - Success1 - Semantic error (e.g., assertion failed)2 - Timeout (e.g., database lock)3 - No data directory found4+ - Other errorsAll diagnostic output goes to stderr. Port numbers and structured output go to stdout, making the tool suitable for command substitution:
port=$(trop reserve) # Only the port number goes to stdout
Control verbosity:
trop --quiet reserve # Minimal output
trop reserve # Normal output
trop --verbose reserve # Detailed output
Or via environment:
export TROP_LOG_MODE=verbose
trop reserve
# Each worktree gets its own port automatically
cd ~/projects/myapp/feature-1
port=$(trop reserve)
cd ~/projects/myapp/feature-2
port=$(trop reserve) # Different port!
Multiple agents working on the same codebase in different directories automatically get non-conflicting ports.
Each test suite run reserves its own ports, preventing interference between parallel test runs.
See the root README for more details.
Generate API documentation:
cargo doc --open
# Run all tests (unit + integration)
cargo test
# Run only CLI integration tests
cargo test --test cli
# Run without building first
cargo run -- --version
# With arguments
cargo run -- --help
troptrop-clitrop library crateThe CLI is a thin wrapper around the trop library, providing command-line parsing and output formatting.
MIT
This is an experimental project in active development. For issues or questions, see the main repository.
This is alpha-stage software. The CLI interface and behavior will change. Not recommended for production use yet.