mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-16 22:10:52 +00:00
cli: improve completion of array arguments
This commit is contained in:
parent
dc5b2bebf1
commit
3b4f6f2d35
@ -84,14 +84,22 @@ fn get_simple_completion(
|
|||||||
if !arg_param.is_empty() {
|
if !arg_param.is_empty() {
|
||||||
let prop_name = arg_param[0];
|
let prop_name = arg_param[0];
|
||||||
if let Some((optional, schema)) = cli_cmd.info.parameters.lookup(prop_name) {
|
if let Some((optional, schema)) = cli_cmd.info.parameters.lookup(prop_name) {
|
||||||
if optional && args[0].starts_with('-') {
|
|
||||||
// argument parameter is optional, and arg looks like an option,
|
let is_array_param = if let Schema::Array(_) = schema { true } else { false };
|
||||||
// so assume its empty and complete the rest
|
|
||||||
|
if (optional || is_array_param) && args[0].starts_with('-') {
|
||||||
|
// argument parameter is optional (or array) , and arg
|
||||||
|
// looks like an option, so assume its empty and
|
||||||
|
// complete the rest
|
||||||
} else {
|
} else {
|
||||||
record_done_argument(done, cli_cmd.info.parameters, prop_name, &args[0]);
|
record_done_argument(done, cli_cmd.info.parameters, prop_name, &args[0]);
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
|
if is_array_param {
|
||||||
|
return get_simple_completion(cli_cmd, done, &arg_param[..], &args[1..]);
|
||||||
|
} else {
|
||||||
return get_simple_completion(cli_cmd, done, &arg_param[1..], &args[1..]);
|
return get_simple_completion(cli_cmd, done, &arg_param[1..], &args[1..]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if args.len() == 1 {
|
if args.len() == 1 {
|
||||||
return get_property_completion(
|
return get_property_completion(
|
||||||
|
Loading…
Reference in New Issue
Block a user