Skip to content

CLI: reject blank and stray flag values; report/merge take --x=value - #122

Merged
tmashara merged 1 commit into
mainfrom
claude/flag-parsing
Nov 2, 2026
Merged

tmashara merged 1 commit into
mainfrom
claude/flag-parsing

Conversation

@tmashara

@tmashara tmashara commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Fixes

  • Blank numeric values: --threshold= and --threshold " " used to read as 0, so the run never failed; now they exit 2 with "--threshold needs a value". --width= and --concurrency= say "needs a value" instead of "got 0".
  • Negative numbers: a numeric flag takes a negative value, so the range check names the problem (--threshold -1 gives "expects 0..1, got -1" instead of "needs a value").
  • =value on flags that take none: --dry-run=false, --progress=false, --computed=false, --no-recheck=x etc. exit 2 with " takes no value". --dry-run=false used to still dry-run.
  • Integer --width: --width 1.5 is rejected at the flag ("--width expects a positive integer"). This matches Config: reject unknown keys, bad widths, non-http origins, blank selectors #120's config widths check.
  • Blank selectors: --selector, --left-selector and --right-selector are trimmed, and a blank one is rejected, as with --mask/--hide.
  • --sitemap guard: a bare --sitemap together with a route or origin ending in .xml now says "use --sitemap=". Before, the file silently became a route (or the right origin) while the default sitemap was fetched.
  • report / merge: they share the main parser's value logic. --x=value works, and a missing value no longer swallows the next flag (--title --markdown f gives "--title needs a value").

All parsers now go through one flags() walker in src/cli.ts. It replaces the inline split/next() and the per-branch blank checks.

Behaviour changes

  • --accept " " now says "--accept needs a value" (was "needs a reason").
  • report --foo=x says "unexpected argument: --foo" (the flag name, without =x).
  • In report/merge, a value starting with - needs the = form: --title=-x. --title -x is rejected.

Testing

typecheck, lint, format:check and npm test pass after the rebase on #120 (388 tests).

  • New cases in tests/unit/cli-args.test.ts: blank numerics, fractional width, =value on boolean flags, the sitemap guard (route and origin forms), a blank selector, and = inside an origin and a route still parsing.
  • New cases in tests/unit/report.test.ts: report --markdown=<file>, report --title with a missing value, merge --out with a missing value.

🤖 Generated with Claude Code

Flag values go through one walker, so a blank value (--threshold= used to
read as 0) and a missing one exit 2 naming the flag, and a flag that takes
no value refuses --flag=value (--dry-run=false used to still dry-run). A
numeric flag takes a negative number so the range check names it. --width
must be a positive integer. A bare --sitemap with a .xml route or origin
asks for --sitemap=<it>. report and merge share the walker: --x=value works
and a missing value no longer swallows the next flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit aa8aeae into main Nov 2, 2026
3 checks passed
@tmashara tmashara mentioned this pull request Nov 2, 2026
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