Closed
Description
Please complete the following tasks
- I have searched the discussions
Rust Version
rustc 1.57.0 (f1edd0429 2021-11-29)
Clap Version
3.1.13
Minimal reproducible code
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! clap = { path = "../clap", features = ["derive"] }
//! ```
fn main() {
let cmd = clap::Command::new("foo").arg(
clap::Arg::new("default")
.short('f')
.long("flag")
.default_value("one,two")
.min_values(0)
.default_missing_value("three,four")
.require_equals(true)
.takes_value(true)
.value_delimiter(','),
);
let matches = cmd.get_matches();
println!("{:?}", matches);
}
Steps to reproduce the bug with the above code
$ ./clap-default.rs
$ ./clap-default.rs --flag
Actual Behaviour
$ ./clap-default.rs
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/epage/src/personal/cargo-script-mvs/target/debug/rust-script ./clap-default.rs`
ArgMatches { args: {[hash: E880D196C5CA4253]: MatchedArg { occurs: 0, source: Some(DefaultValue), indices: [1, 2], type_id: Some(TypeId { t: 15399197027885530680 }), vals: [[AnyValue { inner: TypeId { t: 15399197027885530680 } }, AnyValue { inner: TypeId { t: 15399197027885530680 } }]], raw_vals: [["one", "two"]], ignore_case: false }}, subcommand: None }
$ ./clap-default.rs --flag
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/epage/src/personal/cargo-script-mvs/target/debug/rust-script ./clap-default.rs --flag`
ArgMatches { args: {[hash: E880D196C5CA4253]: MatchedArg { occurs: 1, source: Some(CommandLine), indices: [2], type_id: Some(TypeId { t: 15399197027885530680 }), vals: [[AnyValue { inner: TypeId { t: 15399197027885530680 } }]], raw_vals: [["three,four"]], ignore_case: false }}, subcommand: None }
Expected Behaviour
$ ./clap-default.rs
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/epage/src/personal/cargo-script-mvs/target/debug/rust-script ./clap-default.rs`
ArgMatches { args: {[hash: E880D196C5CA4253]: MatchedArg { occurs: 0, source: Some(DefaultValue), indices: [1, 2], type_id: Some(TypeId { t: 15399197027885530680 }), vals: [[AnyValue { inner: TypeId { t: 15399197027885530680 } }, AnyValue { inner: TypeId { t: 15399197027885530680 } }]], raw_vals: [["one", "two"]], ignore_case: false }}, subcommand: None }
$ ./clap-default.rs --flag
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/epage/src/personal/cargo-script-mvs/target/debug/rust-script ./clap-default.rs --flag`
ArgMatches { args: {[hash: E880D196C5CA4253]: MatchedArg { occurs: 1, source: Some(CommandLine), indices: [2], type_id: Some(TypeId { t: 15399197027885530680 }), vals: [[AnyValue { inner: TypeId { t: 15399197027885530680 } }]], raw_vals: [["three", "four"]], ignore_case: false }}, subcommand: None }
Additional Context
By inspection, it looks like this worked when it was added, see #1587. It was further extended in #2172.
Looks like it was broken in #2297 when switching from add_arg_to_val
to add_multiple_args_to_val
Debug Output
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
fix(parser): Allow delimiting default_missing_values