Merge pull request #104 from marco-m/subcommands-usage-simple
Subcommands usage simple
This commit is contained in:
commit
f5d3733c0a
|
@ -193,7 +193,7 @@ func Example_helpTextWithSubcommand() {
|
|||
MustParse(&args)
|
||||
|
||||
// output:
|
||||
// Usage: example [--verbose]
|
||||
// Usage: example [--verbose] <command> [<args>]
|
||||
//
|
||||
// Options:
|
||||
// --verbose
|
||||
|
|
2
parse.go
2
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
|
||||
}
|
||||
|
||||
|
|
6
usage.go
6
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, " <command> [<args>]")
|
||||
}
|
||||
|
||||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue