A powerful command-line tool for managing and validating environment variables using schema definitions.
- ✅ Validate - Validate environment variables against a schema
- 🩺 Doctor - Actionable diagnostics and suggestions
- 📝 Generate - Generate
.env.examplefiles and documentation from schemas - 🔍 Diff - Compare two environment files with secret protection
cargo install --git https://github.com/eladbash/envctlgit clone https://github.com/eladbash/envctl
cd envctl
cargo build --releasefields:
- key: "DATABASE_URL"
required: true
doc: "Database connection string"
example: "postgresql://user:pass@localhost/db"
secret: false
- key: "API_KEY"
required: true
doc: "API key for external service"
secret: true
- key: "PORT"
required: false
default: "8080"
doc: "Server port"
example: "8080"
secret: falseenvctl validate --schema env.schema.yamlenvctl doctor --schema env.schema.yamlenvctl generate env-example --schema env.schema.yamlenvctl generate docs --schema env.schema.yamlValidate environment variables against the schema.
envctl validate --schema env.schema.yaml [--env .env] [--mode strict|lenient] [--format human|json]Examples:
# Validate process environment
envctl validate --schema env.schema.yaml
# Validate a dotenv file
envctl validate --schema env.schema.yaml --env .env
# JSON output
envctl validate --schema env.schema.yaml --format jsonRun diagnostics and provide actionable feedback.
envctl doctor --schema env.schema.yaml [--env .env] [--mode strict|lenient] [--format human|json]Example output:
Environment Diagnostics Report
Summary:
Missing: 1
Invalid: 0
Unknown: 1
Deprecated: 0
Issues:
[MISSING] DATABASE_URL
Required environment variable is missing
Example: postgresql://user:pass@localhost/db
[UNKNOWN] UNKNOWN_VAR
Unknown environment variable
Suggestions: did you mean DATABASE_URL?
Generate a .env.example file from the schema.
envctl generate env-example --schema env.schema.yaml [--out .env.example]Example output:
# Database connection string
DATABASE_URL=postgresql://user:pass@localhost/db
# API key for external service
API_KEY=<redacted>
# Server port
PORT=8080Generate markdown documentation from the schema.
envctl generate docs --schema env.schema.yaml [--out CONFIG.md]Compare two dotenv files.
envctl diff --schema env.schema.yaml left.env right.env [--fail-on-diff]Example output:
Environment Differences
Missing in left:
- NEW_VAR
Changed values:
PORT: 8080 -> 3000
API_KEY: <hidden> -> <hidden>
| Flag | Description |
|---|---|
--schema <PATH> |
Required - Path to env.schema.yaml |
--env <PATH> |
Optional - Dotenv file path; if omitted, uses process environment |
--mode <strict|lenient> |
Validation mode (default: strict) |
--format <human|json> |
Output format (default: human) |
-q, --quiet |
Reduce output |
--no-color |
Disable ANSI color output |
env-schema- Core schema validation (git dependency)clap- CLI argument parsingserde/serde_json- JSON serializationcolored- ANSI color output
Licensed under the MIT License. See LICENSE for more information.
Made with ❤️ using Rust
