fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true#2269
Open
TimSoethout wants to merge 7 commits intourfave:mainfrom
Open
fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true#2269TimSoethout wants to merge 7 commits intourfave:mainfrom
TimSoethout wants to merge 7 commits intourfave:mainfrom
Conversation
…elp-command fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true
3 tasks
There was a problem hiding this comment.
Pull request overview
Fixes a help-rendering edge case in helpCommandAction where leaf subcommand help could omit GLOBAL OPTIONS when a parent command sets HideHelpCommand: true, by basing “leaf command” detection on visible subcommands rather than raw cmd.Commands length (which can be affected by internal help command injection).
Changes:
- Update leaf-command detection in
helpCommandActionto uselen(cmd.VisibleCommands()) == 0. - Add a regression test to ensure leaf subcommand help still includes
GLOBAL OPTIONSwhenHideHelpCommandis enabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| help.go | Fixes leaf detection for template selection by using visible subcommands, avoiding reliance on injected/hidden help commands. |
| help_test.go | Adds regression coverage for the HideHelpCommand case to ensure GLOBAL OPTIONS are rendered for leaf subcommands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e fix Co-authored-by: TimSoethout <593132+TimSoethout@users.noreply.github.com>
[WIP] Apply changes based on feedback
Co-authored-by: TimSoethout <593132+TimSoethout@users.noreply.github.com>
* Initial plan * Restore docs/go.mod and docs/go.sum to original content Co-authored-by: TimSoethout <593132+TimSoethout@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: TimSoethout <593132+TimSoethout@users.noreply.github.com>
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?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This PR fixes a help-rendering edge case where enabling HideHelpCommand: true on a parent command caused leaf subcommand help to omit GLOBAL OPTIONS.
Decision rationale:
Which issue(s) this PR fixes:
(REQUIRED)
Fixes #2268
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
Release Notes
(REQUIRED)
Fix subcommand help output when
HideHelpCommandis enabled soGLOBAL OPTIONSremain visible for leaf subcommands.