Skip to content

fix: show GLOBAL OPTIONS in SubcommandHelpTemplate#2359

Open
dearchap wants to merge 2 commits into
mainfrom
issue_2076
Open

fix: show GLOBAL OPTIONS in SubcommandHelpTemplate#2359
dearchap wants to merge 2 commits into
mainfrom
issue_2076

Conversation

@dearchap
Copy link
Copy Markdown
Contributor

@dearchap dearchap commented Jun 7, 2026

What type of PR is this?

  • bug

What this PR does / why we need it:

Adds the VisiblePersistentFlags / GLOBAL OPTIONS section to SubcommandHelpTemplate, matching what CommandHelpTemplate already has.

When a subcommand has its own subcommands, DefaultShowSubcommandHelp uses SubcommandHelpTemplate to display help. This template was missing the GLOBAL OPTIONS section, so persistent flags (flags defined on parent commands) were not shown.

This affected the subcommand --help case when the subcommand also has subcommands, AND the subcommand (with no args) help case.

Which issue(s) this PR fixes:

Fixes #2076

Special notes for your reviewer:

Only template.go was modified — the SubcommandHelpTemplate var.

Release Notes

Subcommand help now correctly displays GLOBAL OPTIONS (persistent flags)
when a subcommand has its own subcommands.

SubcommandHelpTemplate was missing the VisiblePersistentFlags section,
so subcommands with their own subcommands would not display GLOBAL OPTIONS
when help was shown via ShowSubcommandHelp.

This aligns SubcommandHelpTemplate with CommandHelpTemplate, which already
includes the GLOBAL OPTIONS section.
@dearchap dearchap requested a review from a team as a code owner June 7, 2026 10:45
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.

Subcommands do not display help for GLOBAL OPTIONS

1 participant