mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
fix: fixes a bug where default values are not applied if the option supports zero values
Closes #1047
This commit is contained in:
parent
326d0a52ce
commit
9c248cbf7d
1 changed files with 8 additions and 1 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue