mirror of https://github.com/status-im/consul.git
Add base command option for hiding generated help for normal args
This commit is contained in:
parent
a2997e2823
commit
8b31eef467
|
@ -33,6 +33,8 @@ type BaseCommand struct {
|
||||||
UI cli.Ui
|
UI cli.Ui
|
||||||
Flags FlagSetFlags
|
Flags FlagSetFlags
|
||||||
|
|
||||||
|
HideNormalFlagsHelp bool
|
||||||
|
|
||||||
flagSet *flag.FlagSet
|
flagSet *flag.FlagSet
|
||||||
hidden *flag.FlagSet
|
hidden *flag.FlagSet
|
||||||
|
|
||||||
|
@ -233,18 +235,20 @@ func (c *BaseCommand) helpFlagsFor(f *flag.FlagSet) string {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
firstCommand := true
|
if !c.HideNormalFlagsHelp {
|
||||||
f.VisitAll(func(f *flag.Flag) {
|
firstCommand := true
|
||||||
// Skip HTTP flags as they will be grouped separately
|
f.VisitAll(func(f *flag.Flag) {
|
||||||
if flagContains(httpFlagsClient, f) || flagContains(httpFlagsServer, f) || flagContains(c.hidden, f) {
|
// Skip HTTP flags as they will be grouped separately
|
||||||
return
|
if flagContains(httpFlagsClient, f) || flagContains(httpFlagsServer, f) || flagContains(c.hidden, f) {
|
||||||
}
|
return
|
||||||
if firstCommand {
|
}
|
||||||
printTitle(&out, "Command Options")
|
if firstCommand {
|
||||||
firstCommand = false
|
printTitle(&out, "Command Options")
|
||||||
}
|
firstCommand = false
|
||||||
printFlag(&out, f)
|
}
|
||||||
})
|
printFlag(&out, f)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return strings.TrimRight(out.String(), "\n")
|
return strings.TrimRight(out.String(), "\n")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue