Open decentral1se opened 13 hours ago
--help/-h appears in both options/global options for sub-commands and that is noisy.
--help/-h
Support only specifying --help/-h as a global option.
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.Help
Incorrect Usage: flag: help requested
cli.HelpFlag = &cli.BoolFlag{ Name: "help", Aliases: []string{"h, H"}, Usage: "Show help", }
Then set HideHelpCommand: true on the root command.
HideHelpCommand: true
Then set HideHelp: true on all sub-commands.
HideHelp: true
Then --help/-h only appears in GLOBAL OPTIONS and not OPTIONS and you do not receive the Incorrect Usage: flag: help requested error.
GLOBAL OPTIONS
OPTIONS
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.
Checklist
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 getIncorrect Usage: flag: help requested
error):Then set
HideHelpCommand: true
on the root command.Then set
HideHelp: true
on all sub-commands.Then
--help/-h
only appears inGLOBAL OPTIONS
and notOPTIONS
and you do not receive theIncorrect Usage: flag: help requested
error.