Repository navigation
Recognize -h/--help at any position and reserve them for help - #257
Merged
Merged
Conversation
- TryShowHelpOrVersion now shows help when -h or --help appears anywhere before the "--" escape (e.g. `list --input foo --help`). --version is still recognized only when passed alone. - Add CAF019 compile error when a parameter name or alias is -h or --help. Previously such options were shadowed by help only when passed alone. - Class based commands (Add<T>) now also go through ValidateCommand. Fixes #248 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
Merged
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 #248
Summary
-h/--helpwas only recognized when it was the single argument, solist --input foo --helpfailed withArgument '--help' is not recognized.even though the usage line shows[options...] [-h|--help].Help at any position
TryShowHelpOrVersion(bothConsoleAppandConsoleAppBuilder) now shows help when-hor--helpappears anywhere before the--escape.--versionis unchanged (recognized only when passed alone).argswith string equality checks before parsing; no allocation.CAF019:
-h/--helpare reservedCAF019when a parameter name (e.g.string help) or a doc comment alias (e.g.-h, host) is-hor--help.app -h), but worked when combined with other arguments (app -h localhost). With help now recognized at any position they would always be shadowed, so this makes the conflict explicit at build time instead.Add<T>) now also go throughValidateCommandso the check applies to them as well.Breaking changes
-hor--help(or a parameter namedhelp) as an option now fails to build withCAF019.-h/--helpcan no longer be passed as an option value (e.g.--message --help) unless it is after--.AddGlobalOption("-h|...")) are not checked at compile time; help takes precedence over them at runtime.Tests
HelpTest: help at any position forRun, builder commands, with global options, and not recognized after--.DiagnosticsTest:CAF019for parameter name, short alias and long alias.🤖 Generated with Claude Code