Skip to content
Discussion options

You must be logged in to vote

Hey! I had a look through the v3 source, and cases 1, 2 and 3 all end up in helpCommandAction, which calls ShowRootCommandHelp for each of them. That is why HelpPrinter turns everything into the same thing. The good news is there are a couple of hooks that let you split them up:

  • cli.ShowRootCommandHelp is a package-level var, so you can replace it. That covers cases 1 and 2 (no args / --help).
  • If you define your own command named help, the built-in one is not added, so you can handle case 3 on its own.
  • Case 4 (myapp mycommand --help) never goes through ShowRootCommandHelp, so it keeps working as before.

Something like this:

cli.ShowRootCommandHelp = func(cmd *cli.Command) error {
    re…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stevewi-niteflyte
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants