fix: use prefixFor for BoolWithInverseFlag names and aliases
BoolWithInverseFlag.String picked - or -- with len(name) == 1, which counts bytes, while the rest of the library uses prefixFor, which counts runes. a one-character non-ascii name or alias was shown as --ü in its help and as -ü for any other flag.
This commit is contained in:
1 parent
ba1266f7c4
commit
544f3ffc57
2 files changed
+15
-10
No files matched your search
@@ -203,12 +203,8 @@ func (bif *BoolWithInverseFlag) String() string {
|
||||
|
||||
i := strings.Index(out, "\t")
|
||||
|
||||
prefix := "--"
|
||||
|
||||
// single character flags are prefixed with `-` instead of `--`
|
||||
if len(bif.Name) == 1 {
|
||||
prefix = "-"
|
||||
}
|
||||
prefix := prefixFor(bif.Name)
|
||||
|
||||
// Guard against a FlagStringer that returns a string without a tab (e.g.
|
||||
// a custom stringer or the default stringer when the flag does not
|
||||
@@ -220,11 +216,7 @@ func (bif *BoolWithInverseFlag) String() string {
|
||||
|
||||
var aliasParts []string
|
||||
for _, alias := range bif.Aliases {
|
||||
aPrefix := "--"
|
||||
if len(alias) == 1 {
|
||||
aPrefix = "-"
|
||||
}
|
||||
aliasParts = append(aliasParts, aPrefix+alias)
|
||||
aliasParts = append(aliasParts, prefixFor(alias)+alias)
|
||||
}
|
||||
|
||||
names := fmt.Sprintf("%s[%s]%s", prefix, bif.inversePrefix(), bif.Name)
|
||||
|
||||
Reference in new issue
Block a user