Use existing prefixedNames
func
This commit is contained in:
parent
7de151883c
commit
6089d723a8
15
flag.go
15
flag.go
@ -645,24 +645,11 @@ func stringifySliceFlag(usage, name string, defaultVals []string) string {
|
|||||||
placeholder = defaultPlaceholder
|
placeholder = defaultPlaceholder
|
||||||
}
|
}
|
||||||
|
|
||||||
nameParts := []string{}
|
|
||||||
for _, part := range strings.Split(name, ",") {
|
|
||||||
nameParts = append(nameParts, strings.TrimSpace(part))
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultVal := ""
|
defaultVal := ""
|
||||||
if len(defaultVals) > 0 {
|
if len(defaultVals) > 0 {
|
||||||
defaultVal = fmt.Sprintf(" (default: %s)", strings.Join(defaultVals, ", "))
|
defaultVal = fmt.Sprintf(" (default: %s)", strings.Join(defaultVals, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal))
|
usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal))
|
||||||
|
return fmt.Sprintf("%s\t%s", prefixedNames(name, placeholder), usageWithDefault)
|
||||||
if len(nameParts) < 2 {
|
|
||||||
return fmt.Sprintf("%s%s %s\t%s", prefixFor(nameParts[0]), nameParts[0],
|
|
||||||
placeholder, usageWithDefault)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%s%s %s, %s%s %s\t%s", prefixFor(nameParts[0]), nameParts[0],
|
|
||||||
placeholder, prefixFor(nameParts[1]), nameParts[1],
|
|
||||||
placeholder, usageWithDefault)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user