fix: fixes a bug where default values are not applied if the option supports zero values

Closes #1047
This commit is contained in:
Kevin K 2017-09-14 10:18:18 -07:00
parent 326d0a52ce
commit 9c248cbf7d
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -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()) {