From b76129e9b71a63365d5c77a7f57b58dbd1e94d49 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Wed, 22 Apr 2015 16:08:34 -0400 Subject: [PATCH] fix(from_usage): fix bug causing args to not be required --- .gitignore | 2 +- src/args/arg.rs | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index bbbb7fbb..dccf408a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ Cargo.lock # Temp files -*~ +.*~ diff --git a/src/args/arg.rs b/src/args/arg.rs index bd939779..7fbec1ef 100644 --- a/src/args/arg.rs +++ b/src/args/arg.rs @@ -211,21 +211,31 @@ impl<'n, 'l, 'h, 'b, 'p, 'r> Arg<'n, 'l, 'h, 'b, 'p, 'r> { UsageToken::Name(n, req) => { if name.is_none() { name = Some(n); - if let Some(m) = req { - required = m; + if let Some(r) = req { + required = r; } - } + } else if let Some(l) = long { + if l == name.unwrap() { + if let Some(r) = req { + required = r; + } + name = Some(n); + } else if n != l { + name = Some(n); + } + + } if short.is_some() || long.is_some() { takes_value = true; } - if let Some(l) = long { - if n != name.unwrap() && name.unwrap() == l { - name = Some(n); - if let Some(m) = req { - required = m; - } - } - } + // if let Some(l) = long { + // if n != name.unwrap() && name.unwrap() == l { + // name = Some(n); + // if let Some(r) = req { + // required = r; + // } + // } + // } }, UsageToken::Short(s) => { short = Some(s);