nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: clap-rs/clap
Pull request #1372 (2018-11-05 03:52:53)

Adding case_insensitive to yaml parsing
There's a missing of setting [case_insensitive](https://github.com/clap-rs/clap/commit/27ecd0d76b331d36d7e1672d20f5a0b6511e3f12) in YAML.


Patch:
diff --git a/src/args/arg.rs b/src/args/arg.rs
index cc4bf128..50a30abb 100644
--- a/src/args/arg.rs
+++ b/src/args/arg.rs
@@ -139,6 +139,7 @@ impl<'a, 'b> Arg<'a, 'b> {
                 "conflicts_with" => yaml_vec_or_str!(v, a, conflicts_with),
                 "overrides_with" => yaml_vec_or_str!(v, a, overrides_with),
                 "possible_values" => yaml_vec_or_str!(v, a, possible_value),
+                "case_insensitive" => yaml_to_bool!(a, v, case_insensitive),
                 "required_unless_one" => yaml_vec_or_str!(v, a, required_unless),
                 "required_unless_all" => {
                     a = yaml_vec_or_str!(v, a, required_unless);


Test patch:
diff --git a/tests/app.yml b/tests/app.yml
index 97d36232..850bb822 100644
--- a/tests/app.yml
+++ b/tests/app.yml
@@ -90,6 +90,11 @@ args:
         multiple: true
         help: Tests 3 max vals
         max_values: 3
+    - case_insensitive:
+        help: Test case_insensitive
+        possible_values: [test123, test321]
+        case_insensitive: true
+
 arg_groups:
     - test:
         args:
Repository: clap-rs/clap
Pull request #1395 (2018-12-13 18:38:40)

fix(macros): fixes broken pattern
I discovered that `default_value_if` cannot be used inside a `clap_app!` macro. The root cause was a bad pattern which did not handle comma-separated arguments. It was probably not spotted before because almost all `Arg` methods take zero or one argument and thus don't need a comma.

This pull request contains a fix for this bug, an extra pattern to handle the unusual but valid case of a trailing comma in the parameters (which can sometimes be inserted by rustfmt), and some tests.


Patch:
diff --git a/src/macros.rs b/src/macros.rs
index eb278956..929c8a2b 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -775,9 +775,13 @@ macro_rules! clap_app {
     (@arg ($arg:expr) $modes:tt $ident:ident[$($target:ident)*] $($tail:tt)*) => {
         clap_app!{ @arg ($arg $( .$ident(stringify!($target)) )*) $modes $($tail)* }
     };
-// Inherit builder's functions
-    (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr)*) $($tail:tt)*) => {
-        clap_app!{ @arg ($arg.$ident($($expr)*)) $modes $($tail)* }
+// Inherit builder's functions, e.g. `index(2)`, `requires_if("val", "arg")`
+    (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr),*) $($tail:tt)*) => {
+        clap_app!{ @arg ($arg.$ident($($expr),*)) $modes $($tail)* }
+    };
+// Inherit builder's functions with trailing comma, e.g. `index(2,)`, `requires_if("val", "arg",)`
+    (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr,)*) $($tail:tt)*) => {
+        clap_app!{ @arg ($arg.$ident($($expr),*)) $modes $($tail)* }
     };
 
 // Build a subcommand outside of an app.


Test patch:
diff --git a/tests/macros.rs b/tests/macros.rs
index 9823fe9c..0cdcb527 100755
--- a/tests/macros.rs
+++ b/tests/macros.rs
@@ -249,6 +249,32 @@ fn group_macro_set_not_required() {
     assert!(!matches.is_present("difficulty"));
 }
 
+#[test]
+fn multiarg() {
+    let app = || clap_app!(
+        claptests =>
+            (@arg flag: --flag "value")
+            (@arg multiarg: --multiarg
+             default_value("flag-unset") default_value_if("flag", None, "flag-set")
+             "multiarg")
+            (@arg multiarg2: --multiarg2
+             default_value("flag-unset") default_value_if("flag", None, "flag-set",)
+             "multiarg2")
+    );
+
+    let matches = app()
+        .get_matches_from_safe(vec!["bin_name"])
+        .expect("match failed");
+    assert_eq!(matches.value_of("multiarg"), Some("flag-unset"));
+    assert_eq!(matches.value_of("multiarg2"), Some("flag-unset"));
+
+    let matches = app()
+        .get_matches_from_safe(vec!["bin_name", "--flag"])
+        .expect("match failed");
+    assert_eq!(matches.value_of("multiarg"), Some("flag-set"));
+    assert_eq!(matches.value_of("multiarg2"), Some("flag-set"));
+}
+
 #[test]
 fn arg_enum() {
     // Helper macros to avoid repetition
Repository: clap-rs/clap
Pull request #1410 (2019-02-04 07:44:21)

fix: add debug assertion for missing args in subcommand ArgGroup
In debug mode, assert that all arguments in a subcommand's required ArgGroup exist when printing the subcommand's help message. The previous behavior was an expectation failure with the generic INTERNAL_ERROR_MSG.

See-also: 7ad123e2c02577 (introduced relevant assertion)


Patch:
diff --git a/src/app/parser.rs b/src/app/parser.rs
index cb367cf6..e3fa1f32 100644
--- a/src/app/parser.rs
+++ b/src/app/parser.rs
@@ -135,7 +135,7 @@ where
     }
 
     #[inline]
-    fn app_debug_asserts(&mut self) -> bool {
+    fn app_debug_asserts(&self) -> bool {
         assert!(self.verify_positionals());
         let should_err = self.groups.iter().all(|g| {
             g.args.iter().all(|arg| {
@@ -512,7 +512,7 @@ where
     pub fn unset(&mut self, s: AS) { self.settings.unset(s) }
 
     #[cfg_attr(feature = "lints", allow(block_in_if_condition_stmt))]
-    pub fn verify_positionals(&mut self) -> bool {
+    pub fn verify_positionals(&self) -> bool {
         // Because you must wait until all arguments have been supplied, this is the first chance
         // to make assertions on positional argument indexes
         //
@@ -1362,6 +1362,8 @@ where
     }
 
     pub fn args_in_group(&self, group: &str) -> Vec<String> {
+        debug_assert!(self.app_debug_asserts());
+
         let mut g_vec = vec![];
         let mut args = vec![];
 


Test patch:
diff --git a/tests/groups.rs b/tests/groups.rs
index fde3f32c..bb108eac 100644
--- a/tests/groups.rs
+++ b/tests/groups.rs
@@ -3,7 +3,7 @@ extern crate regex;
 
 include!("../clap-test.rs");
 
-use clap::{App, Arg, ArgGroup, ErrorKind};
+use clap::{App, Arg, ArgGroup, ErrorKind, SubCommand};
 
 static REQ_GROUP_USAGE: &'static str = "error: The following required arguments were not provided:
     <base|--delete>
@@ -53,6 +53,20 @@ fn non_existing_arg() {
         .get_matches_from_safe(vec![""]);
 }
 
+#[test]
+#[should_panic(expected = "The group 'c' contains the arg 'd' that doesn't actually exist.")]
+fn non_existing_arg_in_subcommand_help() {
+    let _ = App::new("a")
+        .subcommand(
+            SubCommand::with_name("b")
+                .group(
+                    ArgGroup::with_name("c")
+                        .args(&["d"])
+                        .required(true),
+                )
+        ).get_matches_from_safe(vec!["a", "help", "b"]);
+}
+
 #[test]
 fn group_single_value() {
     let res = App::new("group")