From f5dd6f39dc0368c837af003e020059353992e0b3 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Thu, 13 Dec 2018 12:09:52 +0000 Subject: [PATCH 1/3] Auto complete instance arguments to recover command. --- completions/bash/multipass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/bash/multipass b/completions/bash/multipass index b69e48af6c..047ad0b8b3 100644 --- a/completions/bash/multipass +++ b/completions/bash/multipass @@ -93,7 +93,7 @@ _multipass_complete() _multipass_instances "STOPPED" _multipass_instances "SUSPENDED" ;; - "delete"|"info"|"umount"|"unmount") + "delete"|"recover"|"info"|"umount"|"unmount") _multipass_instances ;; "mount") From 3a8861c8dc5091ca56877450b6c62fd995214b3c Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Thu, 13 Dec 2018 12:25:04 +0000 Subject: [PATCH 2/3] Make recover idempotent. Recovering a non-deleted instance is a noop rather than an error. Fixes #526. --- src/daemon/daemon.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 15f345bca6..3ef90bcde1 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1285,13 +1285,11 @@ try // clang-format on if (it == deleted_instances.end()) { it = vm_instances.find(name); - if (it == vm_instances.end()) + if (it == vm_instances.end()) // noop otherwise fmt::format_to(errors, "instance \"{}\" does not exist\n", name); - else - fmt::format_to(errors, "instance \"{}\" has not been deleted\n", name); - continue; } - instances_to_recover.push_back(name); + else + instances_to_recover.push_back(name); } if (errors.size() > 0) From 628ba224fc1dda52ea2aed8ecae217e441c61069 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Thu, 13 Dec 2018 13:04:50 +0000 Subject: [PATCH 3/3] Auto-complete only deleted instances for "recover". Although trying to recover non-deleted instances is not an error, it is not useful either, so they shouldn't be auto-completed. --- completions/bash/multipass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/completions/bash/multipass b/completions/bash/multipass index 047ad0b8b3..581a94c60f 100644 --- a/completions/bash/multipass +++ b/completions/bash/multipass @@ -93,9 +93,12 @@ _multipass_complete() _multipass_instances "STOPPED" _multipass_instances "SUSPENDED" ;; - "delete"|"recover"|"info"|"umount"|"unmount") + "delete"|"info"|"umount"|"unmount") _multipass_instances ;; + "recover") + _multipass_instances "DELETED" + ;; "mount") local source_set=0 local prev