Add default true options handling
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Jun 18, 2016 at 00:19 UTC
1c0f18dfed307a0687cb9407d67a7a311ae9a7cc
1 file changed
+13
-3
commands/cli/helptext.go
+13
-3
@@ -234,10 +234,20 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
234
if len(n) > 1 {
235
pre = "--"
236
}
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
241
} 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
+ }
251
}
252
}
253
res = fmt.Sprintf("%s [%s]", res, sopt)