Repository navigation
Conversation
This branch has not been deployed
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 a root
--verboseflag and adeploychild,app file deploy --verboseruns the root action withverbose=falseand arguments["file", "deploy", "--verbose"]. Replacingdeploywith an ordinary word correctly sets the flag. A command alias has the same effect. A padded first argument," deploy ", also stops parsing even though dispatch preserves it as an argument.parseFlagshands off the remaining arguments whenever a trimmed positional token matches a child, but dispatch only selects a child from the exact first positional argument. If a later argument happens to be a command name, parsing stops and no child takes over.Only hand parsing to a child when the exact first positional argument selects it. The root then parses its remaining flags normally, while first-position command names and aliases still dispatch as before.
Which issue(s) this PR fixes:
No existing issue found. Found with a standalone program using the public API; searches for positional arguments, command names, and
parseFlagsfound no competing fix for this case.Special notes for your reviewer:
#2541 changes the same parser block to handle shorthand command names. I checked this guard together with that change and the other pending command fixes; the combined race suite passes. I will reconcile the small overlap if either parser change lands first.
Testing
On macOS arm64 with Go 1.26.5, based on upstream
d5c06cb:TestCommand_ChildNameAfterPositionalArgumentfails for a later command name, a later alias, and a command name following an empty argument. The ordinary-argument and first-position dispatch controls pass. Those six cases pass with the initial fix; stashing only that production change reproduces the three failures. A seventh case for a padded first argument fails on the initial PR head91df506, then passes when lookup uses the exact argument; stashing that follow-up reproduces its failure.verbose=false args=["file" "deploy" "--verbose"]toverbose=true args=["file" "deploy"].make ensure-goimports lint vet testmake test GFLAGS='--tags urfave_cli_no_template'make check-binary-size generate v3diff diffcheckgolangci-lint run: 0 issues.The test targets include the race detector. Linux/Windows and the other CI Go version were not run locally.
Release Notes