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

required_if and and default values #831

Closed
kbknapp opened this issue Jan 30, 2017 · 0 comments
Closed

required_if and and default values #831

kbknapp opened this issue Jan 30, 2017 · 0 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies
Milestone

Comments

@kbknapp
Copy link
Member

kbknapp commented Jan 30, 2017

From #824

extern crate clap;

use clap::{Arg, App};

fn main() {
    let m = App::new("Test app")
        .version("1.0")
        .author("F0x06")
        .about("Arg test")
        .arg(Arg::with_name("target")
            .takes_value(true)
            .default_value("file")
            .possible_values(&["file", "stdout"])
            .long("target"))
        .arg(Arg::with_name("input")
            .takes_value(true)
            .required(true)
            .long("input"))
        .arg(Arg::with_name("output")
            .takes_value(true)
            .required_if("target", "file")
            .long("output"))
        .get_matches_from_safe(vec!["test", "--input", "some"]);

    assert!(m.is_err());
    assert_eq!(m.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
}
@kbknapp kbknapp added A-parsing Area: Parser's logic and needs it changed somehow. D: intermediate C-bug Category: Updating dependencies labels Jan 30, 2017
@kbknapp kbknapp added this to the 2.20.2 milestone Jan 30, 2017
kbknapp added a commit that referenced this issue Feb 1, 2017
@kbknapp kbknapp modified the milestones: 2.20.3, 2.20.2 Feb 3, 2017
kbknapp added a commit that referenced this issue Feb 3, 2017
kbknapp added a commit that referenced this issue Feb 3, 2017
@kbknapp kbknapp closed this as completed in 92919f5 Feb 3, 2017
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