diff --git a/proxmox-router/src/cli/completion.rs b/proxmox-router/src/cli/completion.rs index 109ab3c3..8eacd98a 100644 --- a/proxmox-router/src/cli/completion.rs +++ b/proxmox-router/src/cli/completion.rs @@ -41,18 +41,16 @@ fn get_property_completion( match schema { Schema::String(StringSchema { - format: Some(format), + format: Some(ApiStringFormat::Enum(variants)), .. }) => { - if let ApiStringFormat::Enum(variants) = format { - let mut completions = Vec::new(); - for variant in variants.iter() { - if variant.value.starts_with(arg) { - completions.push(variant.value.to_string()); - } + let mut completions = Vec::new(); + for variant in variants.iter() { + if variant.value.starts_with(arg) { + completions.push(variant.value.to_string()); } - return completions; } + return completions; } Schema::Boolean(BooleanSchema { .. }) => { let mut completions = Vec::new(); diff --git a/proxmox-router/src/cli/completion_helpers.rs b/proxmox-router/src/cli/completion_helpers.rs index 64709d3d..3010ef08 100644 --- a/proxmox-router/src/cli/completion_helpers.rs +++ b/proxmox-router/src/cli/completion_helpers.rs @@ -27,28 +27,26 @@ pub fn complete_file_name(arg: &str, _param: &HashMap) -> Vec return result, }; - for item in dir.iter() { - if let Ok(entry) = item { - if let Ok(name) = entry.file_name().to_str() { - if name == "." || name == ".." { + for entry in dir.iter().flatten() { + if let Ok(name) = entry.file_name().to_str() { + if name == "." || name == ".." { + continue; + } + let mut newpath = dirname.clone(); + newpath.push(name); + + if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty()) + { + if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR { + newpath.push(""); + if let Some(newpath) = newpath.to_str() { + result.push(newpath.to_owned()); + } continue; } - let mut newpath = dirname.clone(); - newpath.push(name); - - if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty()) - { - if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR { - newpath.push(""); - if let Some(newpath) = newpath.to_str() { - result.push(newpath.to_owned()); - } - continue; - } - } - if let Some(newpath) = newpath.to_str() { - result.push(newpath.to_owned()); - } + } + if let Some(newpath) = newpath.to_str() { + result.push(newpath.to_owned()); } } } diff --git a/proxmox-router/src/cli/getopts.rs b/proxmox-router/src/cli/getopts.rs index 3e972fb7..8e2fac19 100644 --- a/proxmox-router/src/cli/getopts.rs +++ b/proxmox-router/src/cli/getopts.rs @@ -74,13 +74,11 @@ pub(crate) fn parse_argument_list>( None => { let mut want_bool = false; let mut can_default = false; - if let Some((_optional, param_schema)) = schema.lookup(&name) { - if let Schema::Boolean(boolean_schema) = param_schema { - want_bool = true; - match boolean_schema.default { - Some(false) | None => can_default = true, - Some(true) => (), - } + if let Some((_optional, Schema::Boolean(boolean_schema))) = schema.lookup(&name) { + want_bool = true; + match boolean_schema.default { + Some(false) | None => can_default = true, + Some(true) => (), } } diff --git a/proxmox-schema/src/format.rs b/proxmox-schema/src/format.rs index 95cb76ce..27d2f3e9 100644 --- a/proxmox-schema/src/format.rs +++ b/proxmox-schema/src/format.rs @@ -126,28 +126,25 @@ pub fn dump_properties( } if style == ParameterDisplayStyle::Config { - match schema { - Schema::String(StringSchema { - format: Some(ApiStringFormat::PropertyString(sub_schema)), - .. - }) => { - match sub_schema { - Schema::Object(object_schema) => { - let sub_text = dump_properties( - object_schema, - &next_indent, - ParameterDisplayStyle::ConfigSub, - &[], - ); - param_descr.push_str(&sub_text); - } - Schema::Array(_) => { - // do nothing - description should explain the list type - } - _ => unreachable!(), + if let Schema::String(StringSchema { + format: Some(ApiStringFormat::PropertyString(sub_schema)), + .. + }) = schema { + match sub_schema { + Schema::Object(object_schema) => { + let sub_text = dump_properties( + object_schema, + &next_indent, + ParameterDisplayStyle::ConfigSub, + &[], + ); + param_descr.push_str(&sub_text); } + Schema::Array(_) => { + // do nothing - description should explain the list type + } + _ => unreachable!(), } - _ => { /* do nothing */ } } } if *optional { diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 592c203e..80204851 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -463,12 +463,10 @@ impl SectionConfig { } else { config[key].as_array_mut().unwrap().push(value); } + } else if config[&key] == Value::Null { + config[key] = value; } else { - if config[&key] == Value::Null { - config[key] = value; - } else { - bail!("duplicate property '{}'", key); - } + bail!("duplicate property '{}'", key); } } else { bail!("syntax error (expected section properties)");