Environment Variable Manager - A powerful CLI tool written in Rust for managing environment variables across different environments (development, staging, production, etc.). Named in honor of Rust's elegant match statement for pattern matching environments.
- π§ Multi-Environment Support - Manage separate variable sets for dev, staging, prod
- π¨ Beautiful TUI Interface - Interactive terminal user interface with Ratatui
- π Easy Environment Switching - Switch between environments with a single command
- β Variable Validation - Ensure required variables are set before deployment
- π Smart Listing - View all variables in any environment
- π― Dual Interface - Both CLI commands and interactive TUI available
- π Local Storage - Variables stored securely in YAML files
- π Fast & Reliable - Built with Rust for performance and safety
# Clone the repository
git clone https://github.com/gonchihernandez/envMatch.git
cd envMatch
# Build the project
cargo build --release
# (Optional) Install globally
cargo install --path .# Install from crates.io (when published)
cargo install envMatch# Download the latest release from GitHub
# Extract and run the binary directly
./envMatch --help# Launch the interactive terminal interface (default when envMatch is initialized)
./envMatch
# or explicitly
./envMatch tuiThe TUI provides a beautiful, interactive interface with:
- π Left Panel: Environment list with current environment highlighted
- π§ Right Panel: Variable list for the selected environment
- β¨οΈ Keyboard Navigation:
Tabto switch between panelsβ/βork/jto navigateato add variables,eto edit,dto deleteEnterto switch environmentshorF1for helpqto quit
# Initialize envMatch in your project
./envMatch init
# Set environment variables
./envMatch set DATABASE_URL postgres://localhost/myapp
./envMatch set API_KEY your_secret_key
./envMatch set DEBUG true
# Create production environment
./envMatch set DATABASE_URL postgres://prod-server/myapp --env production
./envMatch set API_KEY prod_secret_key --env production
./envMatch set DEBUG false --env production
# Switch environments
./envMatch switch production
# List current environment variables
./envMatch list
# Validate required variables
./envMatch validate --required DATABASE_URL,API_KEY./envMatch tui
# or simply
./envMatchLaunches the interactive terminal user interface for visual management of environments and variables.
./envMatch initCreates .envMatch directory structure in your current project.
# Set in current environment (default: development)
./envMatch set KEY value
# Set in specific environment
./envMatch set KEY value --env production# Get from current environment
./envMatch get KEY
# Get from specific environment
./envMatch get KEY --env production# Remove from current environment
cargo run -- unset KEY
# Remove from specific environment
cargo run -- unset KEY --env production# Switch to different environment
cargo run -- switch production
# Show current environment
cargo run -- current
# List all available environments
cargo run -- envs# List variables in current environment
cargo run -- list
# List variables in specific environment
cargo run -- list --env production# Check if required variables are set
cargo run -- validate --required DATABASE_URL,API_KEY
# General environment health check
cargo run -- validateAfter initialization, envMatch creates:
your-project/
βββ .envMatch/
βββ config.yaml # Global configuration
βββ environments/
βββ development.yaml # Development variables
βββ production.yaml # Production variables
βββ staging.yaml # Staging variables (if created)
# 1. Initialize in your project
cargo run -- init
# 2. Set up development environment
cargo run -- set DATABASE_URL postgres://localhost/myapp
cargo run -- set REDIS_URL redis://localhost:6379
cargo run -- set DEBUG true
cargo run -- set LOG_LEVEL debug
# 3. Set up production environment
cargo run -- set DATABASE_URL postgres://prod.example.com/myapp --env production
cargo run -- set REDIS_URL redis://prod.example.com:6379 --env production
cargo run -- set DEBUG false --env production
cargo run -- set LOG_LEVEL info --env production
# 4. Work in development
cargo run -- switch development
cargo run -- list
# Shows all dev variables
# 5. Deploy to production
cargo run -- switch production
cargo run -- validate --required DATABASE_URL,REDIS_URL
# β
All required variables are set in environment 'production'
# 6. Check what environments you have
cargo run -- envs
# π Available environments:
# β’ development
# β’ production (current)- Local Development: Keep dev credentials separate from production
- Testing: Create isolated test environments
- Onboarding: New team members can quickly set up their environment
- Deployment Validation: Ensure all required variables are set before deploy
- Environment Parity: Keep track of what variables exist in each environment
- Configuration Management: Centralized way to manage environment configs
- Consistency: Everyone uses the same variable names and structure
- Documentation: Variables are clearly organized and discoverable
- Security: Sensitive values aren't accidentally committed to git
- Variables are stored in local YAML files
- The
.envMatchdirectory should be added to.gitignore - For production use, consider additional encryption for sensitive values
- Never commit the
.envMatchdirectory to version control
# Run all tests (unit + integration)
cargo test
# Run only unit tests
cargo test --lib
# Run only integration tests
cargo test --test integration_tests
# Run tests with verbose output
cargo test -- --nocapture- Unit Tests: 12 tests covering core functionality
- Integration Tests: 13 tests covering CLI behavior
- Architecture: Modular design with proper error handling
- Test Coverage: All major features and edge cases
The project follows Rust best practices with a modular architecture:
src/
βββ main.rs # CLI entry point and command routing
βββ commands/ # Business logic for each command
β βββ mod.rs # EnvMatchCommands implementation
βββ config/ # Configuration management
β βββ mod.rs # ConfigManager for file operations
βββ error/ # Error handling
βββ mod.rs # Custom error types with thiserror
tests/
βββ integration_tests.rs # End-to-end CLI testing
- Separation of Concerns: Each module has a single responsibility
- Error Handling: Comprehensive error types with helpful messages
- Testability: Dependency injection for easy testing
- Type Safety: Strong typing with custom Result types
- Documentation: Extensive tests serve as documentation
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes
- Run tests:
cargo test - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a Pull Request
- Rust 1.70.0 or higher
- Cargo (comes with Rust)
clap- Command-line argument parsingserde- Serialization/deserializationserde_yaml- YAML file handling
# Run this in your project directory
cargo run -- init# Check what variables exist
cargo run -- list
# Check what environment you're in
cargo run -- current# The environment might not exist yet, create it by setting a variable
cargo run -- set EXAMPLE_VAR example_value --env your_environmentThis project is licensed under the MIT License - see the LICENSE file for details.
- Created by @gonchihernandez
- Built with β€οΈ using Rust
- Inspired by Rust's powerful
matchstatement for pattern matching - Thanks to the Rust community for amazing crates and tools
Made with π¦ Rust - Powered by match πͺ
Original Author: @gonchihernandez