mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
refactor(complete): Simplify num_args lookup
This commit is contained in:
parent
077d714162
commit
7b12c58111
1 changed files with 7 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue