summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2021-04-19 13:21:04 -0700
committerAlex Flint <[email protected]>2021-04-19 13:21:04 -0700
commit9949860eb3d60d374df3a47ebc0a22ca55bba399 (patch)
tree7249f91dec445c4403c715eb4747754452d808bc /usage.go
parent23b96d7aacf62828675decc309eae5b9dce5bd51 (diff)
change "kind" to "cardinality", add support for maps to parser
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/usage.go b/usage.go
index cbbb021..231476b 100644
--- a/usage.go
+++ b/usage.go
@@ -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