| Crates.io | ports-manager |
| lib.rs | ports-manager |
| version | 0.1.0 |
| created_at | 2025-11-11 19:31:06.030763+00 |
| updated_at | 2025-11-11 19:31:06.030763+00 |
| description | A simple, fast, and reliable CLI tool for managing port mappings |
| homepage | https://github.com/mgorunuch/ports-manager |
| repository | https://github.com/mgorunuch/ports-manager |
| max_upload_size | |
| id | 1928072 |
| size | 85,930 |
A simple, fast, and reliable Rust CLI tool for managing port mappings. Configuration is stored in dotfiles at ~/.config/ports-manager/config.toml.
cargo install ports-manager
git clone https://github.com/mgorunuch/ports-manager.git
cd ports-manager
cargo install --path .
Download pre-built binaries for your platform from the releases page.
Ports Manager comes with built-in default ports for 30+ common services that are automatically available. These are stored in ~/.config/ports-manager/defaults.toml and are checked automatically when you use the get command.
Available defaults include:
# Get a default service port (no setup needed!)
ports-manager get postgres
# Outputs: 5432
# Reset defaults to built-in values (if you've modified them)
ports-manager reset-defaults
# Sync defaults with newer versions (preserves ignored entries)
ports-manager sync-defaults
# Customize defaults by editing the file directly
vim ~/.config/ports-manager/defaults.toml
Ignoring Specific Defaults:
Add services to the ignored_defaults array in your config.toml to exclude them from defaults:
# config.toml
ignored_defaults = ["postgres", "mysql"] # Won't use defaults for these
[[ports]]
name = "myapp"
port = 8080
description = "My custom app"
When a service is in ignored_defaults:
defaults.toml# Single port
ports-manager set myapp 8080 --description "My application server"
# Port range
ports-manager set webservices 8000-8010 --description "Web services port range"
# Get existing port
ENV_VAR=$(ports-manager get myapp)
echo $ENV_VAR # Outputs: 8080
# Auto-assign if not configured
PORT=$(ports-manager get mynewapp)
# Automatically finds an available port, saves it, and returns it
# Outputs: 8001 (or next available port)
# Subsequent calls return the same port
PORT=$(ports-manager get mynewapp)
echo $PORT # Outputs: 8001 (same port)
# Works with ranges too
PORT=$(ports-manager get webservices)
echo "Starting on port $PORT" # Outputs: 8000-8010
ports-manager list
ports-manager remove myapp
Ports Manager uses two configuration files:
~/.config/ports-manager/config.toml - Your custom port mappings~/.config/ports-manager/defaults.toml - Default ports for common services (automatically created)When you run get, it:
config.toml)ignored_defaultsdefaults.toml (if not ignored)# Defaults to ignore (won't use defaults.toml for these)
ignored_defaults = ["postgres", "redis"]
# Single port
[[ports]]
name = "myapp"
port = 8080
description = "My application server"
# Port range
[[ports]]
name = "webservices"
description = "Web services port range"
[ports.port]
start = 8000
end = 8010
The defaults file is a clean mapping that syncs automatically. It's replaced during sync-defaults:
version = 1 # Version tracking
[[ports]]
name = "postgres"
port = 5432
description = "PostgreSQL database"
[[ports]]
name = "mysql"
port = 3306
description = "MySQL database"
# ... 28 more services
Note: This file is completely replaced during sync-defaults. To prevent using specific defaults, add them to ignored_defaults in config.toml instead of editing this file.
sync-defaults to get new defaults from updatesignored_defaults array in config to exclude servicesconfig.toml override defaults in defaults.tomldefaults.toml is completely replaced - user customizations go in config.tomlget automatically finds and assigns available ports if not configuredContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/amazing-feature)git commit -m '✨ Add some amazing feature')git push origin feature/amazing-feature)Please make sure to:
cargo fmt and cargo clippy before committingcargo test
cargo clippy --all-targets --all-features
cargo fmt -- --check
cargo build --release
This project is licensed under the MIT License - see the LICENSE file for details.
Built with: