command: simplify duplicate code

This commit is contained in:
Frank Schroeder 2017-10-05 17:49:14 +02:00 committed by Frank Schröder
parent 3028d52158
commit 56ebd5b30f
1 changed files with 3 additions and 9 deletions

View File

@ -210,21 +210,15 @@ func (c *BaseCommand) helpFlagsFor(f *flag.FlagSet) string {
var out bytes.Buffer var out bytes.Buffer
firstHTTP := true if c.hasClientHTTP() || c.hasServerHTTP() {
printTitle(&out, "HTTP API Options")
}
if c.hasClientHTTP() { if c.hasClientHTTP() {
if firstHTTP {
printTitle(&out, "HTTP API Options")
firstHTTP = false
}
httpFlagsClient.VisitAll(func(f *flag.Flag) { httpFlagsClient.VisitAll(func(f *flag.Flag) {
printFlag(&out, f) printFlag(&out, f)
}) })
} }
if c.hasServerHTTP() { if c.hasServerHTTP() {
if firstHTTP {
printTitle(&out, "HTTP API Options")
firstHTTP = false
}
httpFlagsServer.VisitAll(func(f *flag.Flag) { httpFlagsServer.VisitAll(func(f *flag.Flag) {
printFlag(&out, f) printFlag(&out, f)
}) })