cargo-envy-safe

Crates.iocargo-envy-safe
lib.rscargo-envy-safe
version0.1.2
created_at2025-07-20 03:58:20.660017+00
updated_at2025-07-21 15:48:00.06983+00
descriptionA secure and safe CLI to manage .env files in Rust projects
homepagehttps://github.com/chapus/envy-safe
repositoryhttps://github.com/chapus/envy-safe
max_upload_size
id1760785
size24,643
Sergio Pereda Saviรฑรณn (chapus)

documentation

README

envy-safe

A secure, developer-friendly CLI to manage and validate your .env files in Rust projects.

GitHub stars

โœจ Features

  • โœ… Validate .env against .env.example
  • ๐Ÿ”„ Sync missing variables from .env.example
  • ๐Ÿ” Encrypt/decrypt secrets with age
  • ๐Ÿงช GitHub Action for CI validation
  • ๐Ÿ“ฆ Built with Rust, installable via cargo

๐Ÿš€ Installation

cargo install envy-safe

Or clone it and build:

git clone https://github.com/your-user/envy-safe.git
cd envy-safe
cargo build --release

๐Ÿ›  Usage

Check your .env file

envy-safe --check

Will compare .env and .env.example and report missing keys.

Sync missing variables

envy-safe --sync

Adds missing keys from .env.example to .env with example values.


๐Ÿ“ฆ As a Cargo Subcommand

Once installed, you can use envy-safe like any built-in cargo command:

cargo envy-safe --check
cargo envy-safe --sync
cargo envy-safe --encrypt API_KEY
cargo envy-safe --decrypt API_KEY

---

### ๐Ÿ” Encrypting Values

To encrypt values in your `.env` file, set your [age](https://github.com/FiloSottile/age) public key as an environment variable:

```bash
export ENVY_AGE_RECIPIENT="age1xyz..."

Then run:

envy-safe --encrypt API_KEY

You can also create a config file at:

  • Linux/macOS: ~/.config/envy-safe/config.toml
  • Windows: %APPDATA%\envy-safe\config.toml
recipient = "age1xyz..."

If ENVY_AGE_RECIPIENT is not set and no config file is found, encryption will fail with an informative message.


๐Ÿ“‹ Example

Given a .env.example like:

DB_HOST=localhost
DB_PORT=5432
API_KEY=your-api-key

If your .env is missing API_KEY, running --check will show:

Missing key: API_KEY

And running --sync will append the missing key to .env.


๐Ÿ” Coming Soon

  • envy-safe encrypt: Encrypt sensitive variables in .env
  • envy-safe decrypt: Decrypt them for runtime use
  • GitHub Action: Fail CI if .env is out-of-sync

๐Ÿค Contributing

PRs are welcome! Open an issue for feature requests or bugs.

๐Ÿ“„ License

MIT


โญ๏ธ Star This Project

If you find this project useful, please consider giving it a star ๐ŸŒŸ


Made with ๐Ÿ’™ by Sergio

Commit count: 0

cargo fmt