From 4981134708f92ef0d7e9daea1d85afaa2488a3d4 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 13 Mar 2019 12:26:01 +0100 Subject: [PATCH] src/bin/proxmox-backup-client.rs: implement chunk-size completion --- src/bin/proxmox-backup-client.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 6ae03bc6..73ab8e8a 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -78,7 +78,7 @@ fn record_repository(repo: &BackupRepository) { let _ = tools::file_set_contents(path, new_data.to_string().as_bytes(), None); } -fn complete_repository(arg: &str, param: &HashMap) -> Vec { +fn complete_repository(_arg: &str, _param: &HashMap) -> Vec { let mut result = vec![]; @@ -96,7 +96,7 @@ fn complete_repository(arg: &str, param: &HashMap) -> Vec) -> Vec { +fn complete_backup_group(_arg: &str, param: &HashMap) -> Vec { let mut result = vec![]; @@ -617,6 +617,20 @@ fn complete_backup_group(arg: &str, param: &HashMap) -> Vec) -> Vec { + + let mut result = vec![]; + + let mut size = 64; + loop { + result.push(size.to_string()); + size = size * 2; + if size > 4096 { break; } + } + + result +} + fn main() { let repo_url_schema: Arc = Arc::new( @@ -660,7 +674,8 @@ fn main() { )) .arg_param(vec!["repository", "backupspec"]) .completion_cb("repository", complete_repository) - .completion_cb("backupspec", complete_backup_source); + .completion_cb("backupspec", complete_backup_source) + .completion_cb("chunk-size", complete_chunk_size); let list_cmd_def = CliCommand::new( ApiMethod::new(