Skip to content

Commit

Permalink
fix: Multiple defaults combined with ArgEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
plaflamme committed Mar 7, 2022
1 parent 154c0d0 commit b6df23d
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/build/debug_asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,29 @@ fn assert_defaults<'d>(
for default_os in defaults {
if let Some(default_s) = default_os.to_str() {
if !arg.possible_vals.is_empty() {
assert!(
arg.possible_vals.iter().any(|possible_val| {
possible_val.matches(default_s, arg.is_ignore_case_set())
}),
"Argument `{}`'s {}={} doesn't match possible values",
arg.name,
field,
default_s
);
if let Some(delim) = arg.get_value_delimiter() {
for part in default_s.split(delim) {
assert!(
arg.possible_vals.iter().any(|possible_val| {
possible_val.matches(part, arg.is_ignore_case_set())
}),
"Argument `{}`'s {}={} doesn't match possible values",
arg.name,
field,
part
)
}
} else {
assert!(
arg.possible_vals.iter().any(|possible_val| {
possible_val.matches(default_s, arg.is_ignore_case_set())
}),
"Argument `{}`'s {}={} doesn't match possible values",
arg.name,
field,
default_s
);
}
}

if let Some(validator) = arg.validator.as_ref() {
Expand Down

0 comments on commit b6df23d

Please sign in to comment.