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

Fix can not set flag '-h' for custom #619

Closed
wants to merge 1 commit into from

Conversation

chensongz
Copy link
Contributor

Users may want to set flag '-h' for other usage rather than "help".

But function checkCommandHelp and checkSubcommandHelp check every command for flag '-h' and '--help'. User-defined flag '-h' will always show help message.

Only keep flag '--help' more reasonable.

Relate to #546

Copy link
Contributor

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Hi @chensongz

Thanks for starting this! In addition to my comments, do you mind adding tests for this behavior? I'd recommend testing:

  • --help on Apps with no subcommands
  • --help on a subcommand
  • --help on an App with a subcommand (e.g. foo --help bar

@@ -235,7 +235,7 @@ func checkHelp(c *Context) bool {
}

func checkCommandHelp(c *Context, name string) bool {
if c.Bool("h") || c.Bool("help") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be more accurate to call the checkHelp method defined above.

@coilysiren
Copy link
Member

It's been ~2 years since the changes were requested, so I'm comfortable closing this. Please feel free to re-open / create a new PR though!

@coilysiren coilysiren closed this Aug 3, 2019
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.

4 participants