Skip to content

Commit

Permalink
fix: fixes a bug where default values are not applied if the option s…
Browse files Browse the repository at this point in the history
…upports zero values

Closes #1047
  • Loading branch information
kbknapp committed Sep 14, 2017
1 parent 326d0a5 commit 9c248cb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,14 @@ impl<'a, 'b> Parser<'a, 'b>
macro_rules! add_val {
(@default $_self:ident, $a:ident, $m:ident) => {
if let Some(ref val) = $a.v.default_val {
if $m.get($a.b.name).is_none() {
if $m.get($a.b.name).map(|ma| ma.vals.len()).map(|len| len == 0).unwrap_or(false) {
$_self.add_val_to_arg($a, OsStr::new(val), $m)?;

if $_self.cache.map_or(true, |name| name != $a.name()) {
arg_post_processing!($_self, $a, $m);
$_self.cache = Some($a.name());
}
} else {
$_self.add_val_to_arg($a, OsStr::new(val), $m)?;

if $_self.cache.map_or(true, |name| name != $a.name()) {
Expand Down

0 comments on commit 9c248cb

Please sign in to comment.