Adjust display rules

This commit is contained in:
Chris Roberts 2022-01-31 15:11:47 -08:00 committed by Paul Hinze
parent ae9cee6229
commit 08f9eaa603
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -224,6 +224,10 @@ func (g *Group) MapVar(
func (g *Group) Display(
indent int, // Number of spaces to indent
) string {
if g.hidden {
return ""
}
var pad int
opts := []string{}
desc := []string{}
@ -237,9 +241,12 @@ func (g *Group) Display(
} else {
opts = append(opts, " ")
}
if f.kind == BooleanType {
switch f.kind {
case BooleanType:
opts[i] = fmt.Sprintf("%s --[no-]%s", opts[i], f.longName)
} else {
case IncrementType:
opts[i] = fmt.Sprintf("%s --%s", opts[i], f.longName)
default:
opts[i] = fmt.Sprintf("%s --%s VALUE", opts[i], f.longName)
}
desc = append(desc, f.description)
@ -248,6 +255,12 @@ func (g *Group) Display(
}
}
// If there were no flags to display (empty flag collection or all hidden)
// then just return an empty string
if len(opts) == 0 {
return ""
}
pad += indent
var d string