From 4a694f3592b702f86c7a6846b867b61d9feff5fe Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 6 Jun 2022 12:21:47 -0500 Subject: [PATCH] refactor(parser): Be explicit in checking present values --- src/parser/arg_matcher.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/parser/arg_matcher.rs b/src/parser/arg_matcher.rs index 690f504b8cc..b424863e4b7 100644 --- a/src/parser/arg_matcher.rs +++ b/src/parser/arg_matcher.rs @@ -70,11 +70,13 @@ impl ArgMatcher { // We have to check if the parent's global arg wasn't used but still exists // such as from a default value. // - // For example, `myprog subcommand --global-arg=value` where --global-arg defines + // For example, `myprog subcommand --global-arg=value` where `--global-arg` defines // a default value of `other` myprog would have an existing MatchedArg for - // --global-arg where the value is `other`, however the occurs will be 0. + // `--global-arg` where the value is `other` let to_update = if let Some(parent_ma) = vals_map.get(global_arg) { - if parent_ma.get_occurrences() > 0 && ma.get_occurrences() == 0 { + if parent_ma.check_explicit(ArgPredicate::IsPresent) + && !ma.check_explicit(ArgPredicate::IsPresent) + { parent_ma } else { ma