Skip to content

arashrasoulzadeh/devenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

devenv

Deterministic environment configuration management — simple, predictable, and fast.

Build Status Go Report Card License Go Version


Overview

devenv is a CLI tool for managing environment configurations using a layered TOML config.

Define shared values in [base], add per-environment overrides, and generate a clean output file in dotenv, YAML, or TOML format. No duplication, no surprises.


Installation

Homebrew

brew install arashrasoulzadeh/tap/devenv

Manual

curl -L https://github.com/arashrasoulzadeh/devenv/releases/latest/download/devenv-linux -o devenv
chmod +x devenv
sudo mv devenv /usr/local/bin/

Releases: https://github.com/arashrasoulzadeh/devenv/releases


Quick Start

1. Create config.toml

[output]
name = ".env"
type = "dotenv"

[base]
app_name = "myapp"
db_host  = "localhost"
db_user  = "root"

[dev]
db_host = "dev.internal"
db_user = "dev_user"

[prod]
db_host = "db.prod.internal"
db_user = "prod_user"

2. Generate the config file

devenv dev

3. Output (dotenv)

app_name="myapp"
db_host="dev.internal"
db_user="dev_user"

The same config with type = "yaml":

app_name: "myapp"
db_host: "dev.internal"
db_user: "dev_user"

Or type = "toml":

app_name = "myapp"
db_host = "dev.internal"
db_user = "dev_user"

CLI Reference

Generate a config file

devenv [environment]

Merges [base] with the named environment section and writes the output file.

devenv dev      # merge base + [dev], write output
devenv staging  # merge base + [staging], write output
devenv prod     # merge base + [prod], write output
devenv          # write base only (no overlay)

Check missing environment variables

devenv env <environment> [--no-values]

Compares the merged config for the given environment against your current OS environment and reports any keys that are not set.

devenv env dev              # show missing keys with their values
devenv env prod --no-values # show missing keys without exposing values

Other commands

Command Description
devenv help Show help
devenv version Show version and build metadata

Flags

Flag Description
--config FILE Use a custom config file path (default: config.toml)
--dont-commit Dry-run: merge and validate without writing the output file
--no-values Hide values in the missing-keys report (use with env)
--percent show a message with percent of not exists config in env
--json flush messages of log as JSON
--color colorize text output
  • logs and outputs are flushed on defer.
devenv --config path/to/myconf.toml dev
devenv dev --dont-commit
devenv env prod --no-values

Configuration

[output]
name = ".env"       # output file name
type = "dotenv"     # dotenv | yaml | toml

[base]
# shared defaults applied to every environment

[dev]
# keys here override [base] for: devenv dev

[prod]
# keys here override [base] for: devenv prod

Merge rules:

  1. Load [base]
  2. Apply the selected environment's overrides (environment keys win over base)
  3. Render to the configured output format
  4. Write to output.name

How It Works

flowchart TD
    A[CLI Input] --> B[Load config.toml]
    B --> C[base layer]
    C --> D[environment overrides]
    D --> E[merge]
    E --> F[render dotenv / yaml / toml]
    F --> G[write output file]
Loading

CI/CD

devenv prod && export $(cat .env | xargs)

FAQ

Can I define unlimited environments? Yes — any TOML section that is not [base] or [output] is treated as an environment.

What output formats are supported? dotenv, yaml, and toml.

Is the output deterministic? Yes. Keys are always sorted alphabetically, so the file is stable across runs.

What happens if a key only exists in [base] and not in the selected environment? It is included as-is from [base].


Contributing

git clone https://github.com/arashrasoulzadeh/devenv
go test ./...

PRs welcome.


License

MIT © Arash Rasoulzadeh

About

developer env switcher

Topics

Resources

License

Stars

3 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages