do not ignore boolean "noX" options
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 29 Sep 2021 10:46:08 +0000 (12:46 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 29 Sep 2021 10:46:08 +0000 (12:46 +0200)
src/main.rs

index fadb2b9959426332eabe996edd9e43fcb268f001..d677791b88406a9258b9983739c9799c32a70bd5 100644 (file)
@@ -89,7 +89,12 @@ macro_rules! parse_and_apply_options {
         for opt in $in_opts.iter() {
             let mut found = false;
             for opt_def in opt_def.iter() {
-                if opt.name == opt_def.name {
+                let mut matches = opt.name == opt_def.name;
+                if !matches && opt.name.starts_with("no") {
+                    let (_, name) = opt.name.split_at(2);
+                    matches = name == opt_def.name;
+                }
+                if matches {
                     let arg = if let Some(ref str) = opt.value { Some(str) } else { None };
                     let ret = opt_def.parse(&opt.name, arg);
                     if let Ok((val, _)) = ret {