Flags with multiple values wrongly consumes following positional arguments #1610
-
Rust Version
Affected Version of clap
Expected Behavior SummaryGiven a program with the following usage:
where both
should give:
Actual Behavior Summary
gives
Steps to Reproduce the issueN/A Sample Code or Link to Sample CodeApp::new("cksfv.rs")
.arg(Arg::with_name("g")
.short("g")
.value_name("path")
.takes_value(true)
.multiple(true))
.arg(Arg::with_name("file")
.index(1)
.value_name("file")
.multiple(true)) Debug outputCompile clap with cargo features [dependencies]
clap = { version = "2", features = ["debug"] } The output may be very long, so feel free to link to a gist or attach a text file Debug Output
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I think this is intended and the right way. If you want to separate positional arguments from options you have to use |
Beta Was this translation helpful? Give feedback.
-
@pksunkara : even if this is the intended behaviour within |
Beta Was this translation helpful? Give feedback.
-
If you want to implement the CLI as you described, you should use App::new("cksfv.rs")
.arg(Arg::with_name("g")
.short("g")
.value_name("path")
.takes_value(true)
.multiple(true)
.number_of_values(1))
.arg(Arg::with_name("file")
.index(1)
.value_name("file")
.multiple(true)) |
Beta Was this translation helpful? Give feedback.
-
See the documentation at https://docs.rs/clap/2.33.0/i686-apple-darwin/clap/struct.Arg.html#method.multiple |
Beta Was this translation helpful? Give feedback.
-
I guess this is solved, so closing. Feel free to reopen. |
Beta Was this translation helpful? Give feedback.
If you want to implement the CLI as you described, you should use
number_of_values