src/bin/proxmox-backup-manager.rs: improve user list output

This commit is contained in:
Dietmar Maurer 2020-05-01 16:08:15 +02:00
parent 32d83bb34c
commit b080583ba8
2 changed files with 13 additions and 2 deletions

View File

@ -133,8 +133,14 @@ fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Er
let options = default_table_format_options() let options = default_table_format_options()
.column(ColumnConfig::new("userid")) .column(ColumnConfig::new("userid"))
.column(ColumnConfig::new("enable")) .column(
.column(ColumnConfig::new("expire")) ColumnConfig::new("enable")
.renderer(tools::format::render_bool_with_default_true)
)
.column(
ColumnConfig::new("expire")
.renderer(tools::format::render_epoch)
)
.column(ColumnConfig::new("firstname")) .column(ColumnConfig::new("firstname"))
.column(ColumnConfig::new("lastname")) .column(ColumnConfig::new("lastname"))
.column(ColumnConfig::new("email")) .column(ColumnConfig::new("email"))

View File

@ -41,3 +41,8 @@ pub fn render_task_status(value: &Value, record: &Value) -> Result<String, Error
Ok(value.as_str().unwrap_or("unknown").to_string()) Ok(value.as_str().unwrap_or("unknown").to_string())
} }
} }
pub fn render_bool_with_default_true(value: &Value, _record: &Value) -> Result<String, Error> {
let value = value.as_bool().unwrap_or(true);
Ok((if value { "1" } else { "0" }).to_string())
}