From c2043614f73c790ff8c23ace561a988d7c5be1bb Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 27 Feb 2020 12:41:15 +0100 Subject: [PATCH] src/bin/proxmox-backup-client.rs: use new output formath helpers from proxmox 0.15.1-1 --- Cargo.toml | 2 +- src/bin/proxmox-backup-client.rs | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c6b861c..0359892b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ pam = "0.7" pam-sys = "0.5" percent-encoding = "2.1" pin-utils = "0.1.0-alpha" -proxmox = { version = "0.1.14", features = [ "sortable-macro", "api-macro" ] } +proxmox = { version = "0.1.15", features = [ "sortable-macro", "api-macro" ] } #proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] } #proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] } regex = "1.2" diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 73722d0a..c2496661 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -367,7 +367,7 @@ async fn list_backup_groups(param: Value) -> Result { } }); - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + let output_format = get_output_format(¶m); let mut result = vec![]; @@ -434,7 +434,7 @@ async fn list_snapshots(param: Value) -> Result { let repo = extract_repository_from_value(¶m)?; - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + let output_format = get_output_format(¶m); let client = connect(repo.host(), repo.user())?; @@ -465,9 +465,7 @@ async fn list_snapshots(param: Value) -> Result { Ok(tools::join(&files, ' ')) }; - let options = TableFormatOptions::new() - .noborder(false) - .noheader(false) + let options = default_table_format_options() .sortby("backup-type", false) .sortby("backup-id", false) .sortby("backup-time", false) @@ -663,7 +661,7 @@ async fn list_snapshot_files(param: Value) -> Result { let path = tools::required_string_param(¶m, "snapshot")?; let snapshot = BackupDir::parse(path)?; - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + let output_format = get_output_format(¶m); let client = connect(repo.host(), repo.user())?; @@ -681,9 +679,7 @@ async fn list_snapshot_files(param: Value) -> Result { let mut data: Value = result["data"].take(); - let options = TableFormatOptions::new() - .noborder(false) - .noheader(false); + let options = default_table_format_options(); format_and_print_result_full(&mut data, info, &output_format, &options); @@ -708,7 +704,8 @@ async fn list_snapshot_files(param: Value) -> Result { async fn start_garbage_collection(param: Value) -> Result { let repo = extract_repository_from_value(¶m)?; - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + + let output_format = get_output_format(¶m); let mut client = connect(repo.host(), repo.user())?; @@ -1428,7 +1425,8 @@ async fn prune_async(mut param: Value) -> Result { let group = tools::required_string_param(¶m, "group")?; let group = BackupGroup::parse(group)?; - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + + let output_format = get_output_format(¶m); param.as_object_mut().unwrap().remove("repository"); param.as_object_mut().unwrap().remove("group"); @@ -1465,7 +1463,7 @@ async fn status(param: Value) -> Result { let repo = extract_repository_from_value(¶m)?; - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + let output_format = get_output_format(¶m); let client = connect(repo.host(), repo.user())?; @@ -1485,8 +1483,7 @@ async fn status(param: Value) -> Result { Ok(format!("{} {:>8}", v, info)) }; - let options = TableFormatOptions::new() - .noborder(false) + let options = default_table_format_options() .noheader(true) .column(ColumnConfig::new("total").renderer(render_total_percentage)) .column(ColumnConfig::new("used").renderer(render_total_percentage)) @@ -2207,7 +2204,8 @@ fn catalog_mgmt_cli() -> CliCommandMap { /// List running server tasks for this repo user async fn task_list(param: Value) -> Result { - let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); + let output_format = get_output_format(¶m); + let repo = extract_repository_from_value(¶m)?; let client = connect(repo.host(), repo.user())?;