diff --git a/internal/flags/group.go b/internal/flags/group.go index ce53eb0ce..49e85f854 100644 --- a/internal/flags/group.go +++ b/internal/flags/group.go @@ -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