Skip to content

fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true#1

Merged
TimSoethout merged 1 commit intomainfrom
fix-2268-global-options-hide-help-command
Feb 26, 2026
Merged

fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true#1
TimSoethout merged 1 commit intomainfrom
fix-2268-global-options-hide-help-command

Conversation

@TimSoethout
Copy link
Owner

Fixes urfave#2268.

Root cause: help rendering selected template based on raw command count, which changes when HideHelpCommand hides the internal help subcommand.

Change: in helpCommandAction, leaf-command detection now uses visible commands (len(cmd.VisibleCommands()) == 0) so leaf subcommands consistently render with CommandHelpTemplate, including GLOBAL OPTIONS.

Tests: add TestShowSubcommandHelp_GlobalOptions_HideHelpCommand (modeled after TestShowSubcommandHelp_GlobalOptions).

Validation: go test ./... (full suite) passed.

Copilot AI review requested due to automatic review settings February 26, 2026 13:38
@TimSoethout TimSoethout merged commit ffd243e into main Feb 26, 2026
2 checks passed
@TimSoethout TimSoethout deleted the fix-2268-global-options-hide-help-command branch February 26, 2026 13:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes help rendering so leaf subcommands consistently use CommandHelpTemplate (and therefore show GLOBAL OPTIONS) even when HideHelpCommand removes the internal help subcommand and changes the raw subcommand count.

Changes:

  • Update helpCommandAction leaf-command detection to use len(cmd.VisibleCommands()) == 0 instead of len(cmd.Commands)-based heuristics.
  • Add a regression test intended to cover GLOBAL OPTIONS display for --help on a leaf subcommand when HideHelpCommand is enabled.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
help.go Switches leaf detection to “visible subcommands == 0” to choose the command help template consistently.
help_test.go Adds a test for GLOBAL OPTIONS rendering in the HideHelpCommand scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HideHelpCommand: true on a parent command causes missing GLOBAL OPTIONS in subcommand

2 participants