You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me start by saying that this library (crate) is amazing. It has been a lot of fun creating small CLI applications with Rust and this library. This is also my first time submitting an issue on Github.
I have been trying to use the require_unless_one function for an argument. It appears to only work for the first argument name in the array. From the documentation, this works:
let res = App::new("unlessone").arg(Arg::with_name("cfg").required_unless_one(&["dbg","infile"]).takes_value(true).long("config")).arg(Arg::with_name("dbg").long("debug")).arg(Arg::with_name("infile").short("i").takes_value(true)).get_matches_from_safe(vec!["unlessone", "--debug"]);assert!(res.is_ok());let m = res.unwrap();assert!(m.is_present("dbg"));assert!(!m.is_present("cfg"));
But the following does not appear to work:
let res = App::new("unlessone").arg(Arg::with_name("cfg").required_unless_one(&["dbg","infile"]).takes_value(true).long("config")).arg(Arg::with_name("dbg").long("debug")).arg(Arg::with_name("infile").short("i").takes_value(true)).get_matches_from_safe(vec!["unlessone", "-i", "file"]);assert!(res.is_ok());let m = res.unwrap();assert!(m.is_present("infile"));assert!(!m.is_present("cfg"));
Note, I have specified the infile argument, which is the second value in the array for the required_unless_one function. I have forked the repository and added a test for the second example. It currently fails. I have not had a chance to find the issue in the source code yet, but I thought I could at least submit an issue and a pull request that adds the test.
I am using the latest release version of clap (v2.9.2) on Mac OSX with Rust 1.9.0 stable.
The text was updated successfully, but these errors were encountered:
Thanks for filing this, and also the PR 😉 I apologize for the time it's taken me to get to this; I've been traveling for my job. I'm going to look through your PR and we should be able to get this fixed quickly. 👍
Let me start by saying that this library (crate) is amazing. It has been a lot of fun creating small CLI applications with Rust and this library. This is also my first time submitting an issue on Github.
I have been trying to use the
require_unless_one
function for an argument. It appears to only work for the first argument name in the array. From the documentation, this works:But the following does not appear to work:
Note, I have specified the
infile
argument, which is the second value in the array for therequired_unless_one
function. I have forked the repository and added a test for the second example. It currently fails. I have not had a chance to find the issue in the source code yet, but I thought I could at least submit an issue and a pull request that adds the test.I am using the latest release version of clap (v2.9.2) on Mac OSX with Rust 1.9.0 stable.
The text was updated successfully, but these errors were encountered: