A simple command-line tool for managing environment configurations.
First, ensure you have Rust and Cargo installed:
# Check if Cargo is installed
cargo --version || {
echo "Installing Rust and Cargo..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
}Clone the repository and install locally:
# Clone the repository
git clone https://github.com/ncnthien/env-manager.git
cd env-manager
# Build and install
cargo install --path .After installation, ensure that ~/.cargo/bin is in your PATH:
echo $PATH | grep -q "$HOME/.cargo/bin" && echo "Cargo bin is in PATH" || echo "Add ~/.cargo/bin to your PATH"If needed, add to your PATH by adding this line to your shell profile (e.g., ~/.bashrc, ~/.zshrc):
export PATH="$HOME/.cargo/bin:$PATH"Then reload your shell configuration:
source ~/.bashrc # or ~/.zshrcSwitch between different environment configurations:
env-manager switch <environment>Supported environments:
devuatsit
This command copies the content of .env.<environment> to .env.
Add or update the CODE_GEN_TOKEN in your current .env file:
env-manager token <token-value>This command will:
- Read your current
.envfile - Set or replace the
CODE_GEN_TOKENvalue with the provided token - Save the changes back to the
.envfile Display token information:
# Switch to development environment
env-manager switch dev
# Switch to UAT environment
env-manager switch uat
# Add or update a token in the current .env file
env-manager token your-secret-tokenMake sure that you have the corresponding .env.<environment> files in your directory before switching environments.