Test for Issue 1135
It looks like required_unless_one has incorrect behavior if the
argument it applies to also has a short form.
@@ -320,6 +320,22 @@ fn required_unless_one_2() {
assert!(!m.is_present("cfg"));
}
+#[test]
+fn required_unless_one_works_with_short() {
+ // GitHub issue: https://github.com/kbknapp/clap-rs/issues/1135
+ // removing `short("x")` will make this test pass
+ let res = App::new("unlessone")
+ .arg(Arg::with_name("a").conflicts_with("b").short("a"))
+ .arg(Arg::with_name("b").short("b"))
+ .arg(
+ Arg::with_name("x")
+ .short("x")
+ .required_unless_one(&["a", "b"])
+ ).get_matches_from_safe(vec!["unlessone", "-a"]);
+
+ assert!(res.is_ok());
+}
+
#[test]
fn required_unless_one_1() {
let res = App::new("unlessone")
