From 46bcf02a2fccb79ec864308a054bd93158ecdf0f Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sun, 22 Mar 2015 22:26:07 -0400 Subject: [PATCH] Bug fixes --- CHANGELOG | 2 ++ Cargo.toml | 2 +- src/app.rs | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ebc2323c..1540649a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +# v0.4.12 + * Minor bug fixes # v0.4.11 * Bug fixes and cleaned up code organization (well started to...) * Changed runtime representation of arguments to lower allocated memory diff --git a/Cargo.toml b/Cargo.toml index 3b7c11cc..127f0100 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clap" -version = "0.4.11" +version = "0.4.12" authors = ["Kevin K. "] exclude = ["docs/*", "examples/*", "tests/*"] description = "A Command Line Argument Parser written in Rust" diff --git a/src/app.rs b/src/app.rs index d4d116bb..b0555bc1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -694,7 +694,7 @@ impl App { } } - for v in self.flags.values().filter(|&v| v.long.is_some()).filter(|&v| v.long.unwrap() == arg) { + if let Some(v) = self.flags.values().filter(|&v| v.long.is_some()).filter(|&v| v.long.unwrap() == arg).nth(0) { // Ensure this flag isn't on the mutually excludes list if self.blacklist.contains(v.name) { self.report_error(format!("The argument --{} is mutually exclusive with one or more other arguments", arg), @@ -772,9 +772,7 @@ impl App { // Check for matching short in options, and return the name // (only ones with shorts, of course) - for v in self.opts.values().filter(|&v| v.short.is_some()) { - if v.short.unwrap() != arg_c { continue; } - + if let Some(v) = self.opts.values().filter(|&v| v.short.is_some()).filter(|&v| v.short.unwrap() == arg_c).nth(0) { // Ensure this option isn't on the master mutually excludes list if self.blacklist.contains(v.name) { self.report_error(format!("The argument --{} is mutually exclusive with one or more other arguments", arg), @@ -782,7 +780,7 @@ impl App { } if matches.opts.contains_key(v.name) && !v.multiple { - self.report_error(format!("Argument --{} was supplied more than once, but does not support multiple values", arg), true, true); + self.report_error(format!("Argument -{} was supplied more than once, but does not support multiple values", arg), true, true); } matches.opts.insert(v.name, OptArg{