From 59d78cc9bd8ab18d0ec595187fc7871963627dc6 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Thu, 26 Feb 2015 20:31:04 -0500 Subject: [PATCH] v0.0.4.3 --- src/app.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index bbc397b8..eea11792 100644 --- a/src/app.rs +++ b/src/app.rs @@ -129,14 +129,16 @@ impl App { for f in self.flags.iter() { if let Some(l) = f.long { if l == p_arg { + found = true; + let mut mult = false; for ff in matches.flags.iter_mut() { if ff.name == f.name { // already in matches ff.occurrences = if ff.multiple { ff.occurrences + 1 } else { 1 }; - found = true; + mult = true; } } - if ! found { + if ! mult { matches.flags.push(f.clone()) } return ""; @@ -191,9 +193,20 @@ impl App { } for f in self.flags.iter() { if let Some(s) = f.short { - if c == s { + if s == c { found = true; - matches.flags.push(f.clone()); + let mut mult = false; + for ff in matches.flags.iter_mut() { + if ff.name == f.name { + // already in matches + ff.occurrences = if ff.multiple { ff.occurrences + 1 } else { 1 }; + mult = true; + } + } + if ! mult { + matches.flags.push(f.clone()) + } + return ""; } } }