Repository navigation
Refuse an option alias that a standard switch or another option already owns - #34
Merged
Merged
Conversation
…dy owns The parser reads the standard switches before any application option and resolves application options first-match, so a Flag or Option spelled -s, --for, or like an earlier option could never be reached, while --help listed both. Flag and Option now throw ArgumentException naming the alias. Fixes #18 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SwBwi3NknT7dGVuSEED1DX
|
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 #18
What changed
TrayAppBuilder.FlagandTrayAppBuilder.Optionnow throwArgumentExceptionwhen an alias can never be reached. That covers two cases:-t,--tray,--no-tray,-s,--status,-h,--help,-?,-v,--version,-for--for.AppOption.Matchesuses.The message names the conflicting alias, and
ParamNameisaliases.The reserved spellings are in
CommandLineParser.StandardAliases(internal), next to the switch that reads them. Before this, a tool registering-s, --silentgot--statusbehaviour, and--helplisted both options.Tests
Flag_WithAStandardSwitchAlias_Throwsis data-driven over the standard switches.Option_WithAStandardSwitchAlias_ThrowsandFlag_WithAnAliasAnotherOptionTook_Throwseach check that the message names the alias. The last one also checks that the rejected option is not registered.main's builder: all 11 fail there and pass with this change.Note
This is a behaviour change for any tool that registers a clashing alias today. Those tools now fail when the builder runs, instead of silently losing the option. That outcome is what the issue asks for.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SwBwi3NknT7dGVuSEED1DX
Generated by Claude Code