forked from proxmox-mirrors/proxmox
api/cli/completion.rs: implement completion for lists of strings
This commit is contained in:
parent
6fba9bf0bf
commit
48f8e6070d
@ -36,32 +36,35 @@ fn get_property_completion(
|
|||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Schema::String(StringSchema {
|
match schema {
|
||||||
format: Some(format),
|
Schema::String(StringSchema { format: Some(format), .. }) => {
|
||||||
..
|
if let ApiStringFormat::Enum(list) = format {
|
||||||
}) = schema
|
let mut completions = Vec::new();
|
||||||
{
|
for value in list.iter() {
|
||||||
if let ApiStringFormat::Enum(list) = format {
|
if value.starts_with(arg) {
|
||||||
|
completions.push((*value).to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Schema::Boolean(BooleanSchema { .. }) => {
|
||||||
let mut completions = Vec::new();
|
let mut completions = Vec::new();
|
||||||
for value in list.iter() {
|
let mut lowercase_arg = arg.to_string();
|
||||||
if value.starts_with(arg) {
|
lowercase_arg.make_ascii_lowercase();
|
||||||
|
for value in ["0", "1", "yes", "no", "true", "false", "on", "off"].iter() {
|
||||||
|
if value.starts_with(&lowercase_arg) {
|
||||||
completions.push((*value).to_string());
|
completions.push((*value).to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
}
|
Schema::Array(ArraySchema { items, .. }) => {
|
||||||
|
if let Schema::String(_) = items {
|
||||||
if let Schema::Boolean(BooleanSchema { .. }) = schema {
|
return get_property_completion(&items, name, completion_functions, arg, param);
|
||||||
let mut completions = Vec::new();
|
|
||||||
let mut lowercase_arg = arg.to_string();
|
|
||||||
lowercase_arg.make_ascii_lowercase();
|
|
||||||
for value in ["0", "1", "yes", "no", "true", "false", "on", "off"].iter() {
|
|
||||||
if value.starts_with(&lowercase_arg) {
|
|
||||||
completions.push((*value).to_string());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return completions;
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec::new()
|
Vec::new()
|
||||||
|
Loading…
Reference in New Issue
Block a user