Repository navigation
Run a lowercase verb and reject stray arguments instead of ignoring them [patch] - #197
Merged
Merged
Conversation
…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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #195
Summary
Verbs were matched case-sensitively. So
FileDeduplicator scan -p /datanamed no verb, fell through to the defaultMenuverb, read end of input, and exited 0 with nothing scanned. Positional arguments were dropped silently too:Scan -p dir extraignoredextra.Deduplicate dirprompted for the path, and used the pipedymeant for the y/N confirmation as the path.Changes:
Program.CreateParserbuilds the parser withCaseSensitive = false, soscan,SCANandScanall run Scan.Mainuses it, and so does the exit-code test helper, so the tests exercise the real settings.BaseVerb.UnexpectedArgumentsis a hidden[Value(0)]catch-all.BaseVerb<T>.Runchecks it beforeValidateArgs, so before any prompt. If it isn't empty, the run exits 2 and printsUnexpected 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.--help,Scan --helpand the bare menu behave as before. The catch-all is hidden, so it doesn't show up in help.Tests
New
ExitCodeTests:ALowercaseVerbRunsThatVerbAnUnknownVerbExitsTwoAStrayPositionalArgumentExitsTwoAPathGivenWithoutDashPExitsTwoWithoutPromptingAll 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