Skip to content

fix(#46): -h is not a failure, and a rejected flag is reported once - #53

Merged
fgm merged 1 commit into
mainfrom
46-envrun--h-exits-125-and-prints-usage-on-standard-error
Aug 26, 2026
Merged

fgm merged 1 commit into
mainfrom
46-envrun--h-exits-125-and-prints-usage-on-standard-error

Conversation

@fgm

@fgm fgm commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Closes #46. Both symptoms, one commit.

envrun -h printed usage on standard error and exited 125. It now prints usage on standard output and exits 0, reading no environment file and running nothing.

An unknown flag produced three outputs — flag's message, flag's usage block, then envrun's attributed duplicate. It now produces one attributed line followed by usage.

Not the fix the issue proposed

The issue expected -h to arrive as an error needing "a sentinel error or a third return value". envrun declares -h and -help instead: flag's help handling fires only for a name no flag defines, so declaring them means it writes nothing, returns nothing, and the choice of stream is envrun's.

The duplication was propagation, not routing. flag with ContinueOnError reports the error itself and returns it so the caller can stop; envrun treated the return as unreported. Its output is discarded and parseArgs reports instead — it holds the set, so it is the only place that can put usage after the message.

Decisions

  • -h dominates: other flags and the operand are ignored, as sort, curl and python3 do. A -version test must sit below the -h one, or the dominance inverts invisibly.
  • The attribution contract is untouched — 125 still carries envrun failed: — so docs/exit-status.md needed only a qualifier saying -h's 0 is outside the rule.
  • ADR-002 amended: fail/note stay the only diagnostic channel on stderr; output the user asked for goes to stdout.

Tests

The old unknown-flag case could not see the duplication: flag writes to os.Stderr where fail goes through log, so an in-process count in either buffer sees one copy regardless. The replacement is a subprocess with a buffered cmd.Stderr, checked by mutation to fail when the discard is removed.

TestPrefixesMatchTheDocumentation reads docs/exit-status.md and README.md and asserts they quote the prefixes.

#45 shipped as docs only, so this is the change v0.3.0 carries — and its tag is the release pipeline's first live run.

🤖 Generated with Claude Code

@fgm fgm linked an issue Aug 26, 2026 that may be closed by this pull request
@fgm fgm self-assigned this Aug 26, 2026
@fgm fgm added the bug Something isn't working label Aug 26, 2026
@codecov-commenter

codecov-commenter commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (81b78c4) to head (85a45f9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
+ Coverage   98.66%   98.82%   +0.15%     
==========================================
  Files           4        4              
  Lines         150      170      +20     
==========================================
+ Hits          148      168      +20     
  Misses          1        1              
  Partials        1        1              
Flag Coverage Δ
unittests 98.82% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fgm
fgm force-pushed the 46-envrun--h-exits-125-and-prints-usage-on-standard-error branch from f692a2e to 0b1c9e1 Compare August 26, 2026 21:26
- -h previously returned a failing status
- flag previously reported a bad flag twice

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@fgm
fgm force-pushed the 46-envrun--h-exits-125-and-prints-usage-on-standard-error branch from 0b1c9e1 to 85a45f9 Compare August 26, 2026 21:27
@fgm
fgm merged commit 7b43028 into main Aug 26, 2026
7 checks passed
@fgm
fgm deleted the 46-envrun--h-exits-125-and-prints-usage-on-standard-error branch August 26, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

envrun -h exits 125 and prints usage on standard error

2 participants