diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs index 1b05078c..e548fdea 100644 --- a/proxmox-router/src/cli/command.rs +++ b/proxmox-router/src/cli/command.rs @@ -3,8 +3,8 @@ use serde_json::Value; use std::cell::RefCell; use std::sync::Arc; -use proxmox_schema::*; use proxmox_schema::format::DocumentationFormat; +use proxmox_schema::*; use super::environment::CliEnvironment; use super::getopts; diff --git a/proxmox-router/src/cli/completion.rs b/proxmox-router/src/cli/completion.rs index 8eacd98a..af3c6cb1 100644 --- a/proxmox-router/src/cli/completion.rs +++ b/proxmox-router/src/cli/completion.rs @@ -86,7 +86,7 @@ fn get_simple_completion( let prop_name = arg_param[0]; if let Some((optional, schema)) = cli_cmd.info.parameters.lookup(prop_name) { let is_array_param = matches!(schema, Schema::Array(_)); - + 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 diff --git a/proxmox-router/src/cli/completion_helpers.rs b/proxmox-router/src/cli/completion_helpers.rs index 3010ef08..0e8d178f 100644 --- a/proxmox-router/src/cli/completion_helpers.rs +++ b/proxmox-router/src/cli/completion_helpers.rs @@ -1,5 +1,5 @@ -use std::path::PathBuf; use std::collections::HashMap; +use std::path::PathBuf; use nix::dir::Dir; use nix::fcntl::{AtFlags, OFlag}; @@ -21,11 +21,10 @@ pub fn complete_file_name(arg: &str, _param: &HashMap) -> Vec d, - Err(_) => return result, - }; + let mut dir = match Dir::openat(libc::AT_FDCWD, &dirname, OFlag::O_DIRECTORY, Mode::empty()) { + Ok(d) => d, + Err(_) => return result, + }; for entry in dir.iter().flatten() { if let Ok(name) = entry.file_name().to_str() { @@ -35,8 +34,7 @@ pub fn complete_file_name(arg: &str, _param: &HashMap) -> Vec>( None => { let mut want_bool = false; let mut can_default = false; - if let Some((_optional, Schema::Boolean(boolean_schema))) = schema.lookup(&name) { + if let Some((_opt, Schema::Boolean(boolean_schema))) = schema.lookup(&name) { want_bool = true; match boolean_schema.default { Some(false) | None => can_default = true, diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs index cf8dbbd6..a4e4db68 100644 --- a/proxmox-router/src/cli/text_table.rs +++ b/proxmox-router/src/cli/text_table.rs @@ -446,7 +446,10 @@ fn format_table( None => bail!("property {} does not exist in schema.", name), }; - let is_numeric = matches!(prop_schema, Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_)); + let is_numeric = matches!( + prop_schema, + Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_) + ); let (header, right_align, renderer) = options.lookup_column_info(name); @@ -645,7 +648,10 @@ fn format_object( None => bail!("property {} does not exist in schema.", name), }; - let is_numeric = matches!(prop_schema, Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_)); + let is_numeric = matches!( + prop_schema, + Schema::Integer(_) | Schema::Number(_) | Schema::Boolean(_) + ); let (header, right_align, renderer) = options.lookup_column_info(name); diff --git a/proxmox-router/src/permission.rs b/proxmox-router/src/permission.rs index c0075c59..65d2fce3 100644 --- a/proxmox-router/src/permission.rs +++ b/proxmox-router/src/permission.rs @@ -73,7 +73,7 @@ pub trait UserInformation { fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64; } -impl UserInformation for std::sync::Arc { +impl UserInformation for std::sync::Arc { fn is_superuser(&self, userid: &str) -> bool { self.deref().is_superuser(userid) } diff --git a/proxmox-router/src/router.rs b/proxmox-router/src/router.rs index a469891c..22a71808 100644 --- a/proxmox-router/src/router.rs +++ b/proxmox-router/src/router.rs @@ -218,7 +218,7 @@ macro_rules! list_subdirs_api_method { /// # use serde_json::{json, Value}; /// use proxmox_router::{ApiHandler, ApiMethod, Router}; /// use proxmox_schema::ObjectSchema; -/// +/// /// const API_METHOD_HELLO: ApiMethod = ApiMethod::new( /// &ApiHandler::Sync(&|_, _, _| { /// Ok(json!("Hello world!"))