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_value_if with IsPresent doesn't ignore defaults #4918

Open
2 tasks done
epage opened this issue May 18, 2023 · 0 comments
Open
2 tasks done

default_value_if with IsPresent doesn't ignore defaults #4918

epage opened this issue May 18, 2023 · 0 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies
Milestone

Comments

@epage
Copy link
Member

epage commented May 18, 2023

Please complete the following tasks

Rust Version

1.69

Clap Version

4.2.7

Minimal reproducible code

    /// ```rust
    /// # use clap_builder as clap;
    /// # use clap::{Command, Arg, ArgAction};
    /// # use clap::builder::{ArgPredicate};
    /// let m = Command::new("prog")
    ///     .arg(Arg::new("flag")
    ///         .long("flag")
    ///         .action(ArgAction::SetTrue))
    ///     .arg(Arg::new("other")
    ///         .long("other")
    ///         .default_value_if("flag", ArgPredicate::IsPresent, Some("default")))
    ///     .get_matches_from(vec![
    ///         "prog"
    ///     ]);
    ///
    /// assert_eq!(m.get_one::<String>("other"), None);
    /// ```

Steps to reproduce the bug with the above code

Put that in the docs

Actual Behaviour

Panic

Expected Behaviour

Passes

Additional Context

Found via #4904

Holding off until clap v5 in case this is disruptive

Debug Output

No response

@epage epage added C-bug Category: Updating dependencies A-parsing Area: Parser's logic and needs it changed somehow. labels May 18, 2023
@epage epage added this to the 5.0 milestone May 18, 2023
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
Projects
None yet
Development

No branches or pull requests

1 participant