fix(config): derive enum flag usage text from validator values - #406
Conversation
The usage hints for the enum-valued flags were hardcoded and had drifted away from the values their validators actually accept: --dns-mode says <'udp'|'doh'|'sys'>, accepts udp, https, system --https-split-mode lists "sni" twice and omits "first-byte" Following the help text fails: `--dns-mode doh` is rejected with `allowed: udp, https, system`, and docs/user-guide/dns.md correctly documents `--dns-mode "https"`. Render the hints from the same available*Values slices the validators check against, so the two cannot drift apart again, and apply it to --app-mode and --dns-qtype as well. Also fix two references to a nonexistent 'https-split-default' flag in the --https-chunk-size text; the flag is named --https-split-mode. Add a regression test asserting that every enum flag's usage hint lists exactly the values its validator accepts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Heads up that the red
It dies at the checkout step, before commitlint ever runs, so every fork PR hits it Running this repo's own $ echo "fix(config): derive enum flag usage text from validator values" | npx commitlint --verbose
✔ found 0 problems, 0 warnings
$ npx commitlint --from 90441f46c36ba1a23ee391573138e80ec5a18eb2 --to e23ec59bcf9191430256f81cb0031629e07d6571 --verbose
✔ found 0 problems, 0 warningsHappy to send a separate PR for the workflow if that's useful. commitlint only needs The |
|
Thanks for the PR and for flagging the commitlint CI issue! I'll fix the workflow soon. |
|
LGTM |
Problem
The usage hints for the enum-valued flags are hardcoded string literals, and some
have drifted away from the values their validators accept. Following
--helpfails outright:
--helpadvertises--dns-mode<'udp'|'doh'|'sys'>udp,https,system--https-split-mode<"sni"|"random"|"chunk"|"sni"|"custom"|"none">sni,random,chunk,first-byte,custom,noneFor
--dns-mode, onlyudpis correct — DoH ishttpsandsysissystem.docs/user-guide/dns.mdalready documents--dns-mode "https", so the helpoutput is the odd one out. For
--https-split-mode,"sni"is listed twicewhile
first-byteis missing entirely.Separately, the
--https-chunk-sizedescription refers twice to a flag namedhttps-split-default, which does not exist; the flag ishttps-split-mode.Fix
Render the hints from the same
available*Valuesslices the validators checkagainst, through a small
enumUsage()helper, so the text cannot drift awayfrom the behaviour again. Applied to all four enum flags —
--app-modeand--dns-qtypewere already accurate, but they can no longer rot either.No behaviour changes — help text only.
Tests
TestCreateCommand_EnumUsageMatchesValidatorasserts that each enum flag'susage hint lists exactly the values its validator accepts, reading the usage
back through
cli.DocGenerationFlag. I verified it is a real regression test byrestoring the old
<'udp'|'doh'|'sys'>literal and watching it fail.make test,make lintandmake fmt-checkall pass locally (Go 1.27.1, darwin/arm64).🤖 Generated with Claude Code