Skip to content

Run a lowercase verb and reject stray arguments instead of ignoring them [patch] - #197

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/195-unknown-verb-and-stray-arguments
Oct 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/195-unknown-verb-and-stray-arguments

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #195

Summary

Verbs were matched case-sensitively. So FileDeduplicator scan -p /data named no verb, fell through to the default Menu verb, read end of input, and exited 0 with nothing scanned. Positional arguments were dropped silently too:

  • Scan -p dir extra ignored extra.
  • Deduplicate dir prompted for the path, and used the piped y meant for the y/N confirmation as the path.

Changes:

  • Program.CreateParser builds the parser with CaseSensitive = false, so scan, SCAN and Scan all run Scan. Main uses it, and so does the exit-code test helper, so the tests exercise the real settings.
  • BaseVerb.UnexpectedArguments is a hidden [Value(0)] catch-all. BaseVerb<T>.Run checks it before ValidateArgs, so before any prompt. If it isn't empty, the run exits 2 and prints Unexpected argument: bogus. Commands: Deduplicate, DryRun, Scan, Stats. Give the path with -p. That covers an unknown verb (which lands on Menu as a positional), a stray extra argument, and a path given without -p.
  • The README's Commands section now says that command names match in any case, and that unknown commands and stray arguments exit 2.

--help, Scan --help and the bare menu behave as before. The catch-all is hidden, so it doesn't show up in help.

Tests

New ExitCodeTests:

  • ALowercaseVerbRunsThatVerb
  • AnUnknownVerbExitsTwo
  • AStrayPositionalArgumentExitsTwo
  • APathGivenWithoutDashPExitsTwoWithoutPrompting

All four fail with the case-insensitivity and the positional check disabled, and pass with them. Full suite: 110 passed, 3 skipped. The skips are the existing permission tests, which can't run as root.


Generated by Claude Code

…hem [patch]

Verbs matched case-sensitively, so `scan -p /data` named no verb, fell
through to the default Menu verb, read end of input and exited 0 with nothing
scanned. Positional arguments were dropped silently too: `Scan -p dir extra`
ignored "extra", and `Deduplicate dir` prompted for the path and consumed the
piped "y" meant for the confirmation as the answer.

Program.CreateParser builds the parser with CaseSensitive = false, and Main
and the exit-code tests use it. BaseVerb collects positional arguments in a
hidden catch-all, and BaseVerb<T>.Run exits 2 with a one-line message naming
the commands when there are any, before any prompt.

Fixes #195

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3PPqgYMrM7WRJp2UF
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit cd7579b into main Oct 30, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/195-unknown-verb-and-stray-arguments branch October 30, 2026 02:57
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.

A lowercase or misspelled verb (scan -p /data) silently opens the menu and exits 0 without scanning; stray positional arguments are ignored

2 participants