From f98ea63de2b4b0392d3a3655af25e3bc4e91e73a Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 27 Feb 2019 08:38:32 +0100 Subject: [PATCH] src/bin/proxmox-backup-client.rs: fix bash completion --- src/bin/proxmox-backup-client.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 0030cbec..544f671c 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -212,6 +212,24 @@ fn create_backup( //datastore.garbage_collection()?; Ok(Value::Null) + +} + +pub fn complete_backup_source(arg: &str) -> Vec { + + let mut result = vec![]; + + let data: Vec<&str> = arg.splitn(2, ':').collect(); + + if data.len() != 2 { return result; } + + let files = tools::complete_file_name(data[1]); + + for file in files { + result.push(format!("{}:{}", data[0], file)); + } + + result } fn main() { @@ -250,7 +268,7 @@ fn main() { ) )) .arg_param(vec!["repository", "backupspec"]) - .completion_cb("backupspec", tools::complete_file_name); + .completion_cb("backupspec", complete_backup_source); let list_cmd_def = CliCommand::new( ApiMethod::new(