api/cli/completion.rs: implement completion for lists of strings

This commit is contained in:
Dietmar Maurer 2020-04-23 10:58:16 +02:00
parent 6fba9bf0bf
commit 48f8e6070d

View File

@ -36,11 +36,8 @@ fn get_property_completion(
return completions;
}
if let Schema::String(StringSchema {
format: Some(format),
..
}) = schema
{
match schema {
Schema::String(StringSchema { format: Some(format), .. }) => {
if let ApiStringFormat::Enum(list) = format {
let mut completions = Vec::new();
for value in list.iter() {
@ -51,8 +48,7 @@ fn get_property_completion(
return completions;
}
}
if let Schema::Boolean(BooleanSchema { .. }) = schema {
Schema::Boolean(BooleanSchema { .. }) => {
let mut completions = Vec::new();
let mut lowercase_arg = arg.to_string();
lowercase_arg.make_ascii_lowercase();
@ -63,6 +59,13 @@ fn get_property_completion(
}
return completions;
}
Schema::Array(ArraySchema { items, .. }) => {
if let Schema::String(_) = items {
return get_property_completion(&items, name, completion_functions, arg, param);
}
}
_ => {}
}
Vec::new()
}