-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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(task): subcommand parser skips global args #15297
Conversation
Hi @Cre3per! I'm not a maintainer just someone interested in seeing this patch merged! I just noticed that it looks like you have to sign the CLA if you want this code to be reviewed. Thanks either way! |
Thanks for the reminder @niedzielski ! I pushed commits with a wrong email address, which I later amended, and thought the CLA checker was just slow to pick up the changes. I now force-pushed onto my fork. |
@@ -2582,8 +2593,6 @@ fn task_parse( | |||
} | |||
|
|||
if let Some(mut index) = matches.index_of("task_name_and_args") { |
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 index being out of sync with the raw_args index seems a bit error prone. In the interest of merging this for the release tomorrow, I'm going to push a change that keeps these in sync.
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.
Ok, I couldn't figure it out in a reasonable time. I moved this current code to be localized and your fix seems to work in a bunch of scenarios I tried so let's land it. Thanks!
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.
LGTM. Thanks!
Fixes #15290
I decided to slice
args
inflags_from_vec()
, rather than intask_parse()
, to avoid passingtask_parse()
more data than is necessary. This makes it easier to see thattask_parse()
doesn't care about the "--quiet" indeno --quiet task echo
.Not happy with the way I'm slicing the subcommand's args from
args
. I couldn't find anything in clap to get the index of the subcommand name, or a function likeindex_of()
for subcommands. Suggestions are welcome.