refactor(complete): Simplify num_args lookup

This commit is contained in:
Ed Page 2024-08-15 15:06:19 -05:00
parent 077d714162
commit 7b12c58111

View file

@ -98,19 +98,15 @@ pub fn complete(
parse_positional(current_cmd, pos_index, is_escaped, state);
}
ParseState::Opt((opt, count)) => match opt.get_num_args() {
Some(range) => {
let max = range.max_values();
if count < max {
state = ParseState::Opt((opt, count + 1));
} else {
state = ParseState::ValueDone;
}
}
None => {
ParseState::Opt((opt, count)) => {
let range = opt.get_num_args().expect("built");
let max = range.max_values();
if count < max {
state = ParseState::Opt((opt, count + 1));
} else {
state = ParseState::ValueDone;
}
},
}
}
}
}