Skip to main content

CLI tool to compare two .env files and report differences

Project description

env-differ

Tests PyPI Python

A CLI tool that compares two .env files and reports differences — missing keys, extra keys, and changed values.
Values are never printed; only key names are shown.


Installation

pip install env-differ

Or install from source for development:

git clone https://github.com/your-org/env-differ.git
cd env-differ
pip install -e ".[dev]"

Usage

env-differ <file_a> <file_b>

file_a is the reference file (e.g. .env.example).
file_b is the file being checked (e.g. .env).

Basic comparison

env-differ .env.example .env

Output example:

Missing keys (in .env.example but not in .env):
  - DATABASE_URL
  - SECRET_KEY

Extra keys (in .env but not in .env.example):
  + DEBUG_VERBOSE

Changed values (key exists in both files but values differ):
  ~ APP_ENV [CHANGED]

No differences

All good! No differences found.

--strict (CI mode)

Exit with code 1 if any missing keys are found. Useful in CI pipelines to ensure a .env file has all required keys from the example.

env-differ --strict .env.example .env
echo $?   # 1 if missing keys, 0 otherwise

GitHub Actions example:

- name: Check .env completeness
  run: env-differ --strict .env.example .env

--json (machine-readable output)

env-differ --json .env.example .env

Output:

{
  "missing": ["DATABASE_URL", "SECRET_KEY"],
  "extra": ["DEBUG_VERBOSE"],
  "changed": ["APP_ENV"],
  "has_differences": true
}

--version

env-differ --version

Help

env-differ --help
env-differ -h

Behaviour notes

  • Lines starting with # and blank lines are ignored.
  • export KEY=VALUE syntax is supported.
  • Surrounding single or double quotes are stripped from values.
  • Actual values are never shown in output (privacy-safe).

Running tests

pytest

With coverage:

pytest --cov=env_differ --cov-report=term-missing

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

env_differ-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_differ-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file env_differ-0.1.0.tar.gz.

File metadata

  • Download URL: env_differ-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for env_differ-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d4909839c3cabe892d235eb84bd843b2b3da2200e88cea4810f8b36cd23b821
MD5 25635e616c45acbe01e949b67553124c
BLAKE2b-256 77d9e0afd28ad37237e92a174144bf34e2e86d7b055e55c0982da611d21bd93e

See more details on using hashes here.

File details

Details for the file env_differ-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: env_differ-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for env_differ-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30160ddf0d7befaabcfcddfd8be44e60ff8440969b2c35bb6ef278ad1e291b6b
MD5 20f861e363d31689f8bf164215be9d29
BLAKE2b-256 0faf8b23d398690a5411063f891fa71685b45f340d5abd6d772cf9847e039152

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page