Skip to content

Add --ignore-extra option - #2

Merged
Gulliby merged 1 commit into
mainfrom
feature/ignore-extra
Oct 12, 2026
Merged

Gulliby merged 1 commit into
mainfrom
feature/ignore-extra

Conversation

@Gulliby

@Gulliby Gulliby commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Before

envguard reported every key in .env that is missing from .env.example as extra: a warning by default, an error with --strict. There was no way to say that some extras are expected, so variables such as CI, CI_JOB_ID or TZ made --strict fail.

After

A new --ignore-extra <KEY> option leaves chosen extra keys out of the report. It can be repeated or given a comma-separated list, and an entry ending in * matches by prefix. Invalid entries (empty, malformed) exit with code 2 and a message on stderr.

$ envguard --strict --ignore-extra "CI*,TZ"
Success: required environment keys are present and non-empty.

With CI, CI_JOB_ID and TZ in .env, plain --strict still exits 1 and lists all three. The README has the option in the table and a full example.

How

  • src/cli.ts: parses and validates the option, adds it to the help text.
  • src/compare.ts: filters extra keys by exact name or prefix.
  • tests/cli.test.ts, tests/compare.test.ts: 26 new tests (108 before, 134 now); existing tests are unchanged.
  • README.md: option row and example.

@Gulliby
Gulliby merged commit e4232ce into main Oct 12, 2026
6 checks passed
@Gulliby
Gulliby deleted the feature/ignore-extra branch October 12, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant