fix: resolve remaining help invocation inconsistencies#2361
Merged
dearchap merged 5 commits intoJun 14, 2026
Conversation
- Add builtInHelp marker to distinguish the built-in help command from user-defined commands with the same name - Fix helpCommandAction to use builtInHelp instead of name matching - Fix checkAllRequiredFlags to use builtInHelp instead of name matching - Add 'Incorrect Usage' prefix to required flag and mutually exclusive flag error paths for consistency with parse error handling - Fix template selection for error paths: use ShowCommandHelp (via parent) instead of ShowSubcommandHelp, so leaf commands get CommandHelpTemplate with their OPTIONS section shown - Fix parse error path (Path D) subcommand case: look up help from parent.Commands instead of cmd.Commands, which was always failing
meatballhat
approved these changes
Jun 14, 2026
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.
What type of PR is this?
What this PR does / why we need it:
Fixes four remaining help invocation inconsistencies:
Built-in help command identity — Added
builtInHelpfield to distinguish the built-in help command from user-defined commands named "help" or "h", preventinghelpCommandActionfrom incorrectly matching user commands."Incorrect Usage" prefix for required flags / mutually exclusive errors — Parse errors printed the prefix but required flag and mutually exclusive errors did not. Now consistent.
Wrong help template for leaf commands on error — Required flag / mutex error paths used
ShowSubcommandHelpwhich always usesSubcommandHelpTemplate, even for leaf commands. Now useShowCommandHelp(ctx, cmd.parent, cmd.Name)which correctly selectsCommandHelpTemplate(with OPTIONS) for leaf commands.Parse error help lookup was broken for subcommands —
ShowCommandHelp(ctx, cmd, cmd.Name)searched cmd in its own Commands (always failing). Fixed toShowCommandHelp(ctx, cmd.parent, cmd.Name).checkAllRequiredFlags uses
cmd.builtInHelpinstead of fragilecmd.Name == helpNamecheck.Which issue(s) this PR fixes:
Related to #2126
Testing
All existing tests pass.