Skip to content

TvoyTezka/env-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotenv-diff

Compare dotenv files and find missing, extra, and empty variables.

Install

Install from the repository:

python -m pip install git+https://github.com/bam0ny/dotenv-diff.git

For local development, install it in editable mode from the project directory:

python -m pip install -e ".[dev]"

Usage

Compare the expected file with the actual file:

dotenv-diff .env.example .env

Example output:

Missing:
  DATABASE_URL
  JWT_SECRET

Extra:
  DEBUG_SQL

Empty:
  REDIS_URL

Use --strict in CI to return exit code 1 when differences are found:

dotenv-diff .env.example .env --strict

Use --json for machine-readable output:

dotenv-diff .env.example .env --json

Show the installed version:

dotenv-diff --version

Create .env.example from .env with empty values:

dotenv-diff --init

When passing paths to --init, the order stays the same as comparison mode: the example file comes first, then the actual file.

dotenv-diff --init .env.example .env

If .env.example already exists, use --force to overwrite it:

dotenv-diff --init --force

Supported dotenv syntax

dotenv-diff supports common .env lines:

DATABASE_URL=postgres://localhost/app
EMPTY=
export DEBUG=true
SECRET="value # not a comment"
TOKEN='abc#123'
HOST=localhost # inline comment

Blank lines and full-line comments are ignored. Lines without = are treated as parse errors so broken configuration fails loudly.

Development

python -m pip install -e ".[dev]"
python -m pytest

License

MIT

About

A small CLI for keeping .env and .env.example files in sync.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages