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/parse.go b/parse.go index 3fcf08a..db9c443 100644 --- a/parse.go +++ b/parse.go @@ -129,7 +129,7 @@ type Parser struct { version string description string - // the following fields change curing processing of command line arguments + // the following field changes during processing of command line arguments lastCmd *command } diff --git a/usage.go b/usage.go index 57935fd..7ee68da 100644 --- a/usage.go +++ b/usage.go @@ -88,6 +88,12 @@ func (p *Parser) writeUsageForCommand(w io.Writer, cmd *command) { fmt.Fprint(w, spec.placeholder) } } + + // if the program supports subcommands, give a hint to the user about their existence + if len(cmd.subcommands) > 0 { + fmt.Fprint(w, " []") + } + fmt.Fprint(w, "\n") }