-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 a regression with parsing multivalue options #5196
Conversation
By default, clap interprets ``` cargo run --bin foo bar baz ``` as ``` cargo run --bin foo --bin bar --bin baz ``` This behavior is different from docopt and does not play nicely with positional arguments at all. Luckily, clap has a flag to get the behavior we want, it just not the default! It will become the default in the next version of clap, but, until that time, we should be careful when using the combination of `.long`, `.value_name` and `.multiple(true)`, and don't forget to specify `.number_of_values(1)` as well.
(rust_highfive has picked a reviewer for you, use r? to override) |
.arg("hello") | ||
.arg("world"), | ||
execs().with_status(0), | ||
); |
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.
Not related to the PR, but do you feel like making p.cargo
a little bit more magical, so that
assert_that(
p.cargo("run --bin foo hello world"),
execs().with_status(0),
);
works?
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.
I'd be totally down for that!
@bors: r+ |
📌 Commit 70ff33a has been approved by |
Fix a regression with parsing multivalue options By default, clap interprets ``` cargo run --bin foo bar baz ``` as ``` cargo run --bin foo --bin bar --bin baz ``` This behavior is different from docopt and does not play nicely with positional arguments at all. Luckily, clap has a flag to get the behavior we want, it just not the default! It will become the default in the next version of clap, but, until that time, we should be careful when using the combination of `.long`, `.value_name` and `.multiple(true)`, and don't forget to specify `.number_of_values(1)` as well. @alexcrichton I'd love to merge this fix before updating cargo at rust-lang/rust :)
☀️ Test successful - status-appveyor, status-travis |
Slightly improve ergonomics of writing Cargo tests As discussed in #5196 (comment) I've also employed this to some of the longer command-lines in our test suite :)
By default, clap interprets
as
This behavior is different from docopt and does not play nicely with
positional arguments at all. Luckily, clap has a flag to get the
behavior we want, it just not the default! It will become the default in
the next version of clap, but, until that time, we should be careful
when using the combination of
.long
,.value_name
and.multiple(true)
, and don't forget to specify.number_of_values(1)
aswell.
@alexcrichton I'd love to merge this fix before updating cargo at rust-lang/rust :)