Fix issue: 2257 Next arg flag name, no default cmd#2258
Open
bbadour wants to merge 5 commits intourfave:mainfrom
Open
Fix issue: 2257 Next arg flag name, no default cmd#2258bbadour wants to merge 5 commits intourfave:mainfrom
bbadour wants to merge 5 commits intourfave:mainfrom
Conversation
If the next argument matches a flag name, and there is no default command, a spurious empty string gets inserted before the flag name. Existing code that expects the flag name in element 0 fails because it is now in element 1 with an empty string in element 0. When there is no default command and an empty string is detected in element 0 (i.e. `cmd.parsedArgs.First()`), change `cmd.parsedArgs` to omit the first empty element.
bbadour
commented
Feb 5, 2026
Author
bbadour
left a comment
There was a problem hiding this comment.
I woud merge the commits into a single commit, but my git is too rusty.
Contributor
|
@bbadour can you add a test ? |
Test fails with recent change and passes with urfave@852060e
Author
Done. |
Author
|
Oh well, heck if I know why gofumpt is complaining. It's not like its giving any useful, actionable information. |
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.
If the next argument matches a flag name, and there is no default command, a spurious empty string gets inserted before the flag name.
Existing code that expects the flag name in element 0 fails because it is now in element 1 with an empty string in element 0.
When there is no default command and an empty string is detected in element 0 (i.e.
cmd.parsedArgs.First()), changecmd.parsedArgsto omit the first empty element.What type of PR is this?
What this PR does / why we need it:
Removes spurious empty string ahead of args when the next argument matches a flag name and there is no DefaultCommand.
Which issue(s) this PR fixes:
Fixes 2257
Testing
Ran tests at my organization that were failing due to the bug.
Release Notes