fix: fixes a bug where default values are not applied if the option supports zero values
Closes
@@ -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()) {
