Reject unknown options on commands that take none - #326
Conversation
Closes Tenacom#314. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude please review this PR. |
|
Claude finished @rdeago's task in 4m 40s —— View job Review: reject unknown options on commands that take noneRic — I read the diff against
Correctness — what I checked and why it holds
I could not run Nits1. Error precedence is now option-before-positional. 2. The new tests assert the type, not the message. Follow-up worth an issue (not this PR)The fix closes the Making the validator the single authority would close it for good — reflect
All pre-existing and clearly out of scope here. Fix this → One editorial question on the changelog
Nothing here blocks merge. If you want, I can apply nits 1 and 2 on this branch. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #326 +/- ##
==========================================
+ Coverage 47.12% 47.27% +0.15%
==========================================
Files 126 126
Lines 4036 4044 +8
Branches 711 714 +3
==========================================
+ Hits 1902 1912 +10
+ Misses 2046 2045 -1
+ Partials 88 87 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
In the typical shape of a botched command line the positionals come first, so `bv clean junk --bogus` now reports 'junk' instead of '--bogus'. Addresses review nit 1 on Tenacom#326. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Asserting only the exception type could not distinguish the alias path from anything else; the interesting fact is that `bv version --bogus` reports the canonical name 'version show'. Also pins the exact wording the changelog promises for `bv clean --bogus`. Addresses review nit 2 on Tenacom#326. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CommandArgumentValidator now consumes every option declared via BvOptionAttribute on the command settings type (using ValueName to know which options swallow the following token) and rejects whatever is left, for all non-forwarding commands. A settings-less command is no longer a special case: it just declares zero options. The now-redundant leftover checks in ReleaseSettings.Parse and VersionAdvanceSettings.Parse (with their hardcoded command-name literals) are gone; a future *Settings type cannot reintroduce the silently-ignored-option bug by forgetting them. Since validation runs before the SDK version check, a typo like `bv release --bogus` is now reported even when the repository pins a mismatched SDK version. Addresses the follow-up suggested in the review of Tenacom#326, folded into the PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sync-sdk and version show are new in this same unreleased cycle, so for a reader upgrading from 1.1.10 only clean is a real behavior change; frame the entry as the clean fix plus the general rule, and cover the new report-before-SDK-check timing. Addresses the editorial note in the review of Tenacom#326. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
All four findings addressed, one commit per finding:
Verification: 469 tests pass solution-wide, @claude please take another look. From this round on, flag only merge-blocking issues; anything else, list briefly as non-blocking notes that need no re-review. |
|
Claude finished @rdeago's task in 3m 40s —— View job Re-review: reject unknown options on commands that take noneRead all four commits against
No merge-blocking issues. Ship it. What I verified on the centralization commit (2babf9c)The reflection-driven consumption is the only part with real risk, so I checked it end to end:
Nits 1 and 2 are resolved as described; the alias test now pins CI on head Non-blocking notes — no re-review needed
|
In the typical shape of a botched command line the positionals come first, so `bv clean junk --bogus` now reports 'junk' instead of '--bogus'. Addresses review nit 1 on #326. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Asserting only the exception type could not distinguish the alias path from anything else; the interesting fact is that `bv version --bogus` reports the canonical name 'version show'. Also pins the exact wording the changelog promises for `bv clean --bogus`. Addresses review nit 2 on #326. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CommandArgumentValidator now consumes every option declared via BvOptionAttribute on the command settings type (using ValueName to know which options swallow the following token) and rejects whatever is left, for all non-forwarding commands. A settings-less command is no longer a special case: it just declares zero options. The now-redundant leftover checks in ReleaseSettings.Parse and VersionAdvanceSettings.Parse (with their hardcoded command-name literals) are gone; a future *Settings type cannot reintroduce the silently-ignored-option bug by forgetting them. Since validation runs before the SDK version check, a typo like `bv release --bogus` is now reported even when the repository pins a mismatched SDK version. Addresses the follow-up suggested in the review of #326, folded into the PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Closes #314.
Option validation lived in two places:
CommandArgumentValidator(forwarded tokens, excess positionals) and each command's*Settings.Parse(leftover option tokens). Commands with no settings type —clean,sync-sdk,version show— fell through both nets, sobv clean --bogusran normally and typos went unnoticed.CommandArgumentValidatoris now the single authority for unknown-option rejection: it consumes every option declared viaBvOptionAttributeon the command's settings type (ValueNametells it which options swallow the following token) and rejects whatever is left, asUnknown option '--bogus' for command 'clean'. A settings-less command is simply one that declares zero options — no special case. The now-redundant leftover checks inReleaseSettings.ParseandVersionAdvanceSettings.Parseare gone, so a future*Settingstype cannot reintroduce the bug by forgetting the check. Offending tokens are reported in command-line order (excess positionals before unknown options), and — since validation runs before the SDK version check —bv release --bogusnow reports the typo even in a repository with a mismatched SDK pin.Note: the issue names
cleanandversion show;sync-sdkis settings-less too and is covered by the same fix.Note: the first review round suggested centralizing unknown-option rejection as a follow-up issue. It is folded into this PR instead: the changes are small and self-contained, and a separate PR wasn't worth the overhead.
Verification
clean --bogus, andversion --boguspinning the canonicalversion showname in the message) and for settings-carrying commands (release --bogus); declared options consumed correctly (space-separated and inline values, flags, missing-value error);clean junk --bogusreportsjunkfirst.dotnet bv packgreen; ReSharperinspectcode --swea --severity=WARNING: zero results.🤖 Generated with Claude Code