diff --git a/example_test.go b/example_test.go index ea123e4..be3cd12 100644 --- a/example_test.go +++ b/example_test.go @@ -193,7 +193,7 @@ func Example_helpTextWithSubcommand() { MustParse(&args) // output: - // Usage: example [--verbose] + // Usage: example [--verbose] [] // // Options: // --verbose diff --git a/usage.go b/usage.go index 57935fd..b07280b 100644 --- a/usage.go +++ b/usage.go @@ -88,6 +88,13 @@ func (p *Parser) writeUsageForCommand(w io.Writer, cmd *command) { fmt.Fprint(w, spec.placeholder) } } + + // if the program supports subcommands and the command-line doesn't contain any, + // give a hint to the user about the existence of these subcommands. + if len(p.cmd.subcommands) > 0 && p.cmd == cmd { + fmt.Fprint(w, " []") + } + fmt.Fprint(w, "\n") }