diff options
| author | Alex Flint <[email protected]> | 2021-04-19 19:27:31 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-19 19:27:31 -0700 |
| commit | 6a01a15f75472271568c732c1191e9d33a5fc54c (patch) | |
| tree | 4accbdd65152994d4e2b043ad81751dce86af93e /usage.go | |
| parent | f4eb7f3a585abd65b0568428b2b9fde8cebffb6a (diff) | |
| parent | d4b9b2a00813ef6f28f75a685bd868aab4609ec4 (diff) | |
Merge pull request #149 from alexflint/parse-into-map
Add support for parsing into a map
Diffstat (limited to 'usage.go')
| -rw-r--r-- | usage.go | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -95,7 +95,7 @@ func (p *Parser) writeUsageForCommand(w io.Writer, cmd *command) { for _, spec := range positionals { // prefix with a space fmt.Fprint(w, " ") - if spec.multiple { + if spec.cardinality == multiple { if !spec.required { fmt.Fprint(w, "[") } @@ -213,16 +213,16 @@ func (p *Parser) writeHelpForCommand(w io.Writer, cmd *command) { // write the list of built in options p.printOption(w, &spec{ - boolean: true, - long: "help", - short: "h", - help: "display this help and exit", + cardinality: zero, + long: "help", + short: "h", + help: "display this help and exit", }) if p.version != "" { p.printOption(w, &spec{ - boolean: true, - long: "version", - help: "display version and exit", + cardinality: zero, + long: "version", + help: "display version and exit", }) } @@ -249,7 +249,7 @@ func (p *Parser) printOption(w io.Writer, spec *spec) { } func synopsis(spec *spec, form string) string { - if spec.boolean { + if spec.cardinality == zero { return form } return form + " " + spec.placeholder |
