Metadata-Version: 2.4
Name: envexample-guard
Version: 0.1.0
Summary: Detect drift between your .env and .env.example files. Zero dependencies, CI-friendly exit codes.
License-Expression: MIT
Keywords: dotenv,env,environment,config,ci,lint
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# envexample-guard

Catch the classic "works on my machine" bug: someone added `STRIPE_KEY` to
`.env.example`, but your `.env` never got it (or vice versa).

`envexample-guard` compares a `.env` file against its `.env.example` template and
reports **missing**, **extra**, and **empty** keys. It has zero dependencies and
returns non-zero exit codes, so it drops straight into CI or a pre-commit hook.

## Install

```bash
pip install envexample-guard
```

## Usage

```bash
envexample-guard                         # compares ./.env against ./.env.example
envexample-guard --env .env.local --example .env.template
envexample-guard --strict                # also fail on keys not in the example
envexample-guard --no-empty              # also fail on required keys with empty values
envexample-guard --json                  # machine-readable output
envexample-guard --write-example         # regenerate .env.example from .env (values stripped)
```

Example output:

```
✗ missing (in .env.example, not in .env): DATABASE_URL, STRIPE_KEY
! extra   (in .env, not in .env.example): OLD_FLAG
```

### Exit codes

| code | meaning |
|------|---------|
| 0    | in sync |
| 1    | drift detected (missing keys; extra keys with `--strict`; empty values with `--no-empty`) |
| 2    | a file could not be read |

### In CI (GitHub Actions)

```yaml
- run: pip install envexample-guard
- run: envexample-guard --env .env.ci --example .env.example --strict
```

## Python API

```python
from envexample_guard import parse_dotenv, compare

report = compare(parse_dotenv(".env"), parse_dotenv(".env.example"))
print(report.missing, report.extra, report.empty)
```

## Parsing rules

Supports `KEY=value`, `export KEY=value`, single/double quoted values (with
`\n` escapes in double quotes), multi-line quoted values, inline `# comments`
after unquoted values, blank lines and comment lines.

## License

MIT
