Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use usage template in subcommand help #1986

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

meatballhat
Copy link
Member

What type of PR is this?

  • bug

What this PR does / why we need it:

Use existing usage template in subcommand help to remove (confusing) difference between templates.

Which issue(s) this PR fixes:

Closes #1879

to remove (confusing) difference between templates.

Closes #1879
@meatballhat meatballhat added the area/v2 relates to / is being considered for v2 label Oct 14, 2024
@meatballhat meatballhat added this to the Release 2.x milestone Oct 14, 2024
@meatballhat meatballhat requested a review from a team as a code owner October 14, 2024 01:28
Copy link
Member

@BlackHole1 BlackHole1 left a comment

Choose a reason for hiding this comment

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

LGTM

@vimiix
Copy link
Contributor

vimiix commented Oct 14, 2024

@meatballhat Do we need to display different formats depending on whether there are subcommands?

For example, fix the templ variable in ShowSubcommandHelp function like this:

templ := SubcommandHelpTemplate
if cCtx.Command != nil {
  if cCtx.Command.CustomHelpTemplate != "" {
    templ = cCtx.Command.CustomHelpTemplate
  } else if len(cCtx.Command.VisibleCommands()) == 0 {
    templ = CommandHelpTemplate
  }
}

@meatballhat
Copy link
Member Author

@vimiix good point! I'd like to see if that logic can be part of "usageTemplate" 👀

@dearchap dearchap merged commit 50bdebf into v2-maint Oct 14, 2024
13 checks passed
@dearchap dearchap deleted the v2-use-usage-template-in-subcommand-help branch October 14, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants