urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
22.22k stars 1.7k forks source link

--help takes arguments even for the root command #1809

Closed ianlewis closed 10 months ago

ianlewis commented 1 year ago

When running a command like mycmd --help foo this should trigger help to be printed and ignore other command line arguments but in this case cli will treat foo as an argument to --help and try to print help for the foo command. This results in an error message like

$ mycmd --help foo
mycmd: No help topic for 'foo'
dearchap commented 1 year ago

@ianlewis This is expected behaviour. if someone wants help on a subcmd they can do

$ mycmd --help subcmd

to get the help for subcmd. The workaround for you would be to set a custom App.CommandNotFound func and call ShowSubcommandHelp in that func