Skip to content

Make --help and the README describe what the tool actually does - #72

Merged
korya merged 3 commits into
masterfrom
korya-docs-cli-help
Aug 8, 2026
Merged

korya merged 3 commits into
masterfrom
korya-docs-cli-help

Conversation

@korya

@korya korya commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Problem

Every reference the tool offers disagreed with the tool.

--help could not be used to tell the regexp assertions from the exact-match ones — the single most important distinction in the flag set. --assert-header and --assert-header-eq carried identical text, as did --assert-redirect and --assert-redirect-eq, and --assert-body advertised an equality check it has never performed.

--assert-ok claimed "successful (2xx)" while passing anything below 400. Verified against a live endpoint:

$ http-assert --assert-ok http://github.com
[:] HTTP/1.1 301 Moved Permanently
[+] PASSED                                    # exit 0

-v said it logs info and selects debug; -s said it filters and selects error. -m carried double spaces imported from curl's man page, where they were troff formatting.

And --help never mentioned the exit code — the tool's entire output — nor the six options settable from the environment, nor that the transport already honours HTTP_PROXY:

$ http-assert --help | grep -icE 'HTTP_ASSERT|exit code|proxy'
0

Solution

Descriptions now name the range, level or match semantics they actually implement, and --help grew a section covering exit codes, the HTTP_ASSERT_* variables with their precedence, and proxy support.

The 2xx-or-3xx behaviour is documented rather than narrowed. Test_AssertStatusOK pins 300, 301, 307 and 399 as OK, so it is intentional — curl -f semantics. Worth knowing that since redirects are not followed, a health check aimed at an endpoint that starts redirecting to a login page stays green.

Both header assertions fall back to a presence check when handed a bare name, which the descriptions now say — it is also why asserting a header equals the empty string is not expressible.

A new end-to-end test pins the help text against the harness's own exit-code constants rather than against literals, so the four places these codes now live cannot drift apart quietly. Both of its failure modes were confirmed by mutation before commit, because a guard that has never failed is not a guard.

Other Changes

Exit code 2 is deliberately not documented, contrary to what #24 asked for. It was the Go panic path; #61 removed it and the hostile-input probe keeps it removed, so listing it would document something that can no longer happen. The test asserts its absence.

#24's remaining item — 93 conflating "service down" with "service wrong" — is a behaviour change and moved to #71.

Notes for the reviewer

The Long text carries a trap worth knowing about: the flag-panic probe locates the flag list by cutting --help at the first "Flags:", so that string appearing in the prose above would silently point it at the wrong section — and a probe that reads no flags is a probe that passes. The new test asserts there is exactly one occurrence.

The README's assertion table was already correct about regexp vs exact matching; only its --assert-ok row was wrong. #37 is narrower than filed — a --help-only bug.

Closes #20
Closes #24
Closes #30
Closes #37
Closes #39
Closes #40
Closes #46

🤖 Generated with Claude Code

korya and others added 3 commits August 7, 2026 23:14
--help is the only reference available at the terminal, and it could not be
used to tell the regexp assertions from the exact-match ones -- the single
most important distinction in the flag set. --assert-header and
--assert-header-eq carried identical text, as did --assert-redirect and
--assert-redirect-eq, and --assert-body advertised an equality check it has
never performed.

--assert-ok said "successful (2xx)" while passing anything below 400. That
is deliberate, and pinned as such by Test_AssertStatusOK, which asserts 300,
301, 307 and 399 are OK -- curl -f semantics. Since redirects are not
followed, a health check aimed at an endpoint that starts redirecting to a
login page stays green, so the description now says which range it accepts
rather than implying a narrower one.

-v selects debug and -s selects error; the descriptions claimed info and a
filter over it. Both now name the level they are equivalent to.

Both header assertions fall back to a presence check when given a bare name,
which is worth knowing at the point of use: it is also why asserting that a
header equals the empty string is not expressible.

And -m loses the double spaces it inherited from curl's man page, where they
were troff formatting.

Closes #20
Closes #30
Closes #37
Closes #40

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP
The exit code is this tool's entire output, and --help never mentioned one.
Nor did it reveal that six options can be set without touching the command
line, or that the transport already honours HTTP_PROXY, HTTPS_PROXY and
NO_PROXY -- so users behind a corporate proxy went looking for a flag that
does not exist, and users with the variable set for unrelated reasons had
their health checks silently rerouted with nothing to explain it.

The README documents the first two. It is not what anybody reaches for with
a terminal already open.

Exit code 2 is deliberately absent. It was the Go panic path; #61 removed it
and the hostile-input probe keeps it removed, so listing it would document
something that can no longer happen.

The new test pins all of this against the harness's own exit-code constants
rather than against literals, so the prose and the contract cannot drift
apart quietly. It also guards a trap this change created: the flag-panic
probe locates the flag list by cutting the help output at the first
"Flags:", and that string appearing in the prose above would silently point
it at the wrong section -- a probe that reads no flags is a probe that
passes. Both failure modes were confirmed by mutation before committing.

Closes #24
Closes #39
Closes #46

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP
The assertion table promised a 2xx check from a flag that passes anything
below 400. Since redirects are not followed, that gap is exactly where a
health check quietly succeeds against an endpoint now redirecting to a login
page.

Proxying has always worked and nothing said so, which fails in both
directions: users behind a corporate proxy assume it does not, and users
with the variable set for unrelated reasons cannot explain why their checks
reach the wrong host.

The rest of the assertion table was already right -- it distinguished the
regexp flags from the exact-match ones correctly, which --help did not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EMMhgmTkbzAsmeNy97PrP
@korya
korya marked this pull request as ready for review August 8, 2026 03:18
@korya
korya merged commit 1277e7c into master Aug 8, 2026
8 checks passed
@korya
korya deleted the korya-docs-cli-help branch August 8, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment