cli
cli copied to clipboard
How to print command helpscreen
From time to time I want to show an error and then command helpscreen.
if args.Len() < 3 {
fmt.Printf("You must choose at least 3 files!\")
// --- the place
return cli.Exit("some text", 3)
}
How can I print the same screen as prints ./program help or ./program module help?
@unera Depending on whether the command is a root command or is a subcommand you could use one of the following
ShowAppHelpAndExit or ShowSubcommandHelpAndExit
@dearchap thanks, that works fine
But I have another question
I have an application that can have options at levels,
example:
foo [global opts] command [command opts] subcommand [subcommand opts]
But when I call ShowSubcommandHelpAndExit, it showes helpscreen that contains only description
foo command [command options]
Is there a way to show global options, too at the helpscreen?
Or at least note about they are exists and full list can be found at foo help screen?
@unera You can try using
ShowAppHelp(rootCommand)