1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 17:03:58 +08:00

Add default true options handling

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera
2016-06-18 00:19:59 +02:00
parent f144a84247
commit 1c0f18dfed

View File

@ -234,12 +234,22 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
if len(n) > 1 { if len(n) > 1 {
pre = "--" pre = "--"
} }
if opt.Type() == cmds.Bool && opt.DefaultVal() == true {
pre = "--"
sopt = fmt.Sprintf("%s%s=false", pre, n)
break
} else {
if i == 0 { 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) sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt)
}
} else { } else {
sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n) sopt = fmt.Sprintf("%s | %s%s", sopt, pre, n)
} }
} }
}
res = fmt.Sprintf("%s [%s]", res, sopt) res = fmt.Sprintf("%s [%s]", res, sopt)
} }
if len(cmd.Arguments) > 0 { if len(cmd.Arguments) > 0 {