Repository navigation
fix: use prefixFor for BoolWithInverseFlag names and aliases - #2461
Merged
Merged
Conversation
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.
|
Set hardcoded "--" for the name in its "cannot set both flags" error, while the help uses "-" for a one-character name. With Name "e", the help shows -[no-]e, but `-e --no-e` failed with "cannot set both flags `--e` and `--no-e`". Use prefixFor for the name and its inverse, as String does. Fixes: a7514ba ("init inverse falg") Assisted-by: claude:claude-opus-5-5 Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Juneezee
approved these changes
Oct 8, 2026
Juneezee
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks. The two new cases fail without the change and pass with it, and the help output now matches other flags:
GLOBAL OPTIONS:
-[no-]ü (default: false)
--[no-]color, -é (default: false)
-ä
I pushed one more commit for the same mismatch in the "cannot set both flags" error, which still hardcoded -- for the name. With Name: "e", -e --no-e failed with cannot set both flags `--e` and `--no-e` ; it now says -e, with a test for e and ü
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What this PR does / why we need it:
BoolWithInverseFlag.Stringpicks-or--withlen(name) == 1, which counts bytes. the rest of the library usesprefixFor(docs.go), which counts runes, so a one-character non-ascii name or alias is shown as--üin the help of aBoolWithInverseFlagand as-üfor any other flag.flag_bool_with_inverse.go: useprefixForfor the name and for each alias.flag_bool_with_inverse_test.go: two cases inTestBoolWithInverseStringwithüas the name and as an alias.Which issue(s) this PR fixes:
NONE
related #2448 (same alignment for flag suggestions)
Testing
the new cases fail without the change (
--[no-]ü,--[no-]color, --ü) and pass with it.go test ./...,go test -tags urfave_cli_no_template ./...andgo vet ./...pass. no exported api change,godoc-current.txtunchanged.Release Notes