Repository navigation
fix: name a short flag with its dash when it needs an argument in a group - #2499
Merged
Juneezee merged 1 commit intoOct 25, 2026
Merged
Conversation
…roup A short flag missing its argument was reported as "flag needs an argument: -n" on its own but as "flag needs an argument: n" inside a group (-avn, or -nv where it isn't last). v2 printed "-n" in both cases; the group paths now do too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vidigoat
force-pushed
the
fix/short-group-missing-argument-dash
branch
from
October 25, 2026 11:56
5ed8048 to
9a4d8ce
Compare
Juneezee
approved these changes
Oct 25, 2026
Juneezee
left a comment
Member
There was a problem hiding this comment.
Thanks! The fix is right and minimal. I updated one sentence in the description: v2.27.7 gave no error for -nv, because it took -v as the value of -n.
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:
With
UseShortOptionHandling, a short flag that is missing its argument is reported with its dash on its own, but without it inside a group:TestParseAndRunShortOptsshows both forms next to each other (test -iexpects-i,test -iaexpectsi). v2.27.7 printed-nfor-nand-avn, and the other parse errors also name the flag with a dash (flag provided but not defined: -invalid). The two group paths inparseFlagsnow format it as-%c, like the single-flag path.Which issue(s) this PR fixes:
None, found by running the same command lines against v2.27.7 and v3.
Testing
-ia/-aiccases inTestParseAndRunShortOptsandTestCommand_UseShortOptionHandlingMultiByteLastFlagnow expect the dash; they fail onmain.-avn,-acand-nagainst v2.27.7: same messages now.make(generate, vet, tests, binary size, gfmrun),make lintandmake v3diffpass.go test -racepasses, as do the tests withurfave_cli_no_template,urfave_cli_no_docsandurfave_cli_no_suggest.The change and the test updates were written with Claude Code (AI).
Release Notes
🤖 Generated with Claude Code