From 1c0f18dfed307a0687cb9407d67a7a311ae9a7cc Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 18 Jun 2016 00:19:59 +0200 Subject: [PATCH] Add default true options handling License: MIT Signed-off-by: Jakub Sztandera --- commands/cli/helptext.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/commands/cli/helptext.go b/commands/cli/helptext.go index 20ca8185f..cd399a04c 100644 --- a/commands/cli/helptext.go +++ b/commands/cli/helptext.go @@ -234,10 +234,20 @@ func generateSynopsis(cmd *cmds.Command, path string) string { if len(n) > 1 { pre = "--" } - if i == 0 { - sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt) + if opt.Type() == cmds.Bool && opt.DefaultVal() == true { + pre = "--" + sopt = fmt.Sprintf("%s%s=false", pre, n) + break } else { - sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n) + if i == 0 { + if opt.Type() == cmds.Bool { + sopt = fmt.Sprintf("%s%s", pre, n) + } else { + sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt) + } + } else { + sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n) + } } } res = fmt.Sprintf("%s [%s]", res, sopt)