Skip to content

Commit

Permalink
refactor(parser): Be explicit in checking present values
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jun 6, 2022
1 parent 805cce7 commit 4a694f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/parser/arg_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a694f3

Please sign in to comment.