-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't remove flag value that matches subcommand name #1781
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overall makes sense but since we'd be changing the API from
...
we'd have to wait for Cobra 2.0.0.
Disregard! I've been doing rust too long - these aren't exported
any update? |
I don't think there are any outstanding questions or changes requested, so it waiting on further review or approval. |
@brianpursley Thanks for your reply. I'm waiting for this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me and I think it is safe with respect to backwards-compatibility.
It will fix the broken case, which I don't see anyone expecting to work as it does now.
Since this PR requires a small rebase, I allowed myself to add two nits that hopefully @brianpursley won't mind addressing at the same time.
Thanks for your patience.
When the command searches args to find the arg matching a particular subcommand name, it needs to ignore flag values, as it is possible that the value for a flag might match the name of the sub command. This change improves argsMinusFirstX() to ignore flag values when it searches for the X to exclude from the result.
bdbdf95
to
b9dae33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix!
LGTM
@marckhouzam please milestone this! |
This was already milestoned 🙂 |
When the command searches args to find the arg matching a particular subcommand name, it needs to ignore flag values, as it is possible that the value for a flag might match the name of the sub command. This change improves argsMinusFirstX() to ignore flag values when it searches for the X to exclude from the result. Fixes spf13/cobra#1777 Merge spf13/cobra#1781
When the command searches args to find the arg matching a particular subcommand name, it needs to ignore flag values, as it is possible that the value for a flag might match the name of the sub command.
This change improves argsMinusFirstX() to ignore flag values when it searches for the X to exclude from the result.
Fixes #1777