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

--help/-h only in GLOBAL OPTIONS? #1989

Open
3 tasks done
decentral1se opened this issue Oct 21, 2024 · 2 comments
Open
3 tasks done

--help/-h only in GLOBAL OPTIONS? #1989

decentral1se opened this issue Oct 21, 2024 · 2 comments
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this

Comments

@decentral1se
Copy link

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here.
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

--help/-h appears in both options/global options for sub-commands and that is noisy.

Solution description

Support only specifying --help/-h as a global option.

Describe alternatives you've considered

There is currently a (potentially unknown?) hack to make this work. What you need to do:

Set cli.Help on your root command (otherwise you get Incorrect Usage: flag: help requested error):

	cli.HelpFlag = &cli.BoolFlag{
		Name:    "help",
		Aliases: []string{"h, H"},
		Usage:   "Show help",
	}

Then set HideHelpCommand: true on the root command.

Then set HideHelp: true on all sub-commands.

Then --help/-h only appears in GLOBAL OPTIONS and not OPTIONS and you do not receive the Incorrect Usage: flag: help requested error.

@decentral1se decentral1se added area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this labels Oct 21, 2024
@decentral1se decentral1se changed the title --help/-h only in GLOBAL OPTIONS? v3: --help/-h only in GLOBAL OPTIONS? Oct 21, 2024
@decentral1se decentral1se changed the title v3: --help/-h only in GLOBAL OPTIONS? --help/-h only in GLOBAL OPTIONS? Oct 21, 2024
@decentral1se
Copy link
Author

There is an additional inconsistency that sub-commands that are not leaf commands show --help/-h in OPTIONS regardless of the above hack. And HideHelp: true then actually hides the flag.

@dearchap dearchap assigned dearchap and unassigned dearchap Oct 26, 2024
@dearchap
Copy link
Contributor

@decentral1se want to make a PR for the fix ? Would be happy to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this
Projects
None yet
Development

No branches or pull requests

2 participants