Skip to content

Reject unconsumed CLI arguments instead of silently dropping them - #172

Merged
androidand merged 3 commits into
mainfrom
feat/170-reject-unconsumed-cli-args
Sep 28, 2026
Merged

androidand merged 3 commits into
mainfrom
feat/170-reject-unconsumed-cli-args

Conversation

@androidand

Copy link
Copy Markdown
Owner

Summary

  • Adds a shared checkArgs/shadowedFlags check, wired into every subcommand's flag parsing, that fails loudly on unconsumed positional arguments and on flags shadowed by an earlier positional token (Go's flag package stops parsing at the first non-flag argument).
  • Adds a pre-flight target/spec-source/change-count summary before any real (non-dry-run) sync write.
  • Adds an AST-based test (TestEveryRunFuncChecksArgs) guarding against a future subcommand silently reintroducing the gap.
  • Regression test reproduces the 2026-09-24 incident's exact argument shape end to end against a stub gh.

Closes #170

🤖 Generated with Claude Code

…ng them

Adds a shared checkArgs/shadowedFlags check, wired into every subcommand's
flag parsing, that fails loudly on two compounding defects behind the
2026-09-24 incident: leftover positional arguments (an unset -change means
"sync everything") and flags shadowed by an earlier positional token (Go's
flag package stops parsing at the first non-flag argument, so a trailing
-dry-run was never even seen). Also adds a pre-flight target/count summary
before any real sync write, and a regression test reproducing the incident's
exact argument shape end to end against a stub gh.
- shadowedFlags no longer under-counts: the value-token skip only applies
  before the positional boundary (where flag.Parse genuinely consumes a
  value), so two shadowed flags in a row (e.g. a value flag immediately
  followed by a bool flag) are both reported instead of just the first.
- checkArgsErr no longer names the same shadowed flag twice (once as
  "shadowed", once as "unexpected argument") — the unexpected-argument list
  excludes tokens already reported as shadowed flags.
- Added TestEveryRunFuncChecksArgs: an AST-based guard so a future
  subcommand can't silently reintroduce this incident's failure mode by
  omitting the checkArgs call.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying specsync with  Cloudflare Pages  Cloudflare Pages

Latest commit: a8ff489
Status: ✅  Deploy successful!
Preview URL: https://37417f0d.specsync.pages.dev
Branch Preview URL: https://feat-170-reject-unconsumed-c.specsync.pages.dev

View logs

@androidand
androidand merged commit b410984 into main Sep 28, 2026
2 checks passed
@androidand
androidand deleted the feat/170-reject-unconsumed-cli-args branch September 28, 2026 14:00
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.

Reject unconsumed CLI arguments instead of silently dropping them

1 participant