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:
dualfroz committed 2026-10-07 19:37:46 +02:00
1 parent ba1266f7c4
commit 544f3ffc57
2 files changed
+15 -10

No files matched your search

+13
View File
@@ -367,6 +367,12 @@ func TestBoolWithInverseString(t *testing.T) {
required: true,
expected: "-[no-]e\t",
},
{
testName: "single-char multibyte flag name",
flagName: "ü",
required: true,
expected: "-[no-]ü\t",
},
{
testName: "multi-char flag name",
flagName: "env",
@@ -412,6 +418,13 @@ func TestBoolWithInverseString(t *testing.T) {
aliases: []string{"c"},
expected: "--[no-]color, -c\t(default: false)",
},
{
testName: "short multibyte alias",
flagName: "color",
required: false,
aliases: []string{"ü"},
expected: "--[no-]color, -ü\t(default: false)",
},
{
testName: "long alias",
flagName: "color",