Skip to content
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

default_missing_value does not respect delimiter #3761

Closed
2 tasks done
epage opened this issue May 27, 2022 · 0 comments
Closed
2 tasks done

default_missing_value does not respect delimiter #3761

epage opened this issue May 27, 2022 · 0 comments
Assignees
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@epage
Copy link
Member

epage commented May 27, 2022

Please complete the following tasks

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

@epage epage added C-bug Category: Updating dependencies A-parsing Area: Parser's logic and needs it changed somehow. E-easy Call for participation: Experience needed to fix: Easy / not much labels May 27, 2022
@epage epage self-assigned this May 27, 2022
@epage epage closed this as completed in ccc809a May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

No branches or pull requests

1 participant