diff options
| author | Alex Flint <[email protected]> | 2020-01-23 11:07:40 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-01-23 11:07:40 -0800 |
| commit | f5d3733c0a632d810fb2f742a1b9caaef85374d9 (patch) | |
| tree | eb38238fdba666065b3fa665a7a6d302118477b9 | |
| parent | ced05bfe8a0f966d6ed09af656f5410bc5f4ed7c (diff) | |
| parent | 9f5522668a8d573c5d5dbe6ee0584f395fba3806 (diff) | |
Merge pull request #104 from marco-m/subcommands-usage-simple
Subcommands usage simple
| -rw-r--r-- | example_test.go | 2 | ||||
| -rw-r--r-- | parse.go | 2 | ||||
| -rw-r--r-- | usage.go | 6 |
3 files changed, 8 insertions, 2 deletions
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] <command> [<args>] // // Options: // --verbose @@ -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 } @@ -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, " <command> [<args>]") + } + fmt.Fprint(w, "\n") } |
