Skip to content

Commit 666a788

Browse files
committed
Add default true options handling
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 1b387d0 commit 666a788

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

commands/cli/helptext.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,20 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
234234
if len(n) > 1 {
235235
pre = "--"
236236
}
237-
if i == 0 {
238-
sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt)
237+
if opt.Type() == cmds.Bool && opt.DefaultVal() == true {
238+
pre = "--"
239+
sopt = fmt.Sprintf("%s%s=false", pre, n)
240+
break
239241
} else {
240-
sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n)
242+
if i == 0 {
243+
if opt.Type() == cmds.Bool {
244+
sopt = fmt.Sprintf("%s%s", pre, n)
245+
} else {
246+
sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt)
247+
}
248+
} else {
249+
sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n)
250+
}
241251
}
242252
}
243253
res = fmt.Sprintf("%s [%s]", res, sopt)

0 commit comments

Comments
 (0)