From 91adbd08d2b781cd13bac49bce5fd87aa1908767 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 16 Mar 2021 10:32:56 +0100 Subject: Fix: Check return value of confirmation prompt This is an embarrassing bug. :-/ Signed-off-by: Matthias Beyer --- src/commands/endpoint_container.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/commands/endpoint_container.rs b/src/commands/endpoint_container.rs index 962b62c..abaf49e 100644 --- a/src/commands/endpoint_container.rs +++ b/src/commands/endpoint_container.rs @@ -73,23 +73,33 @@ pub async fn container(endpoint_names: Vec, kill(matches, container).await }, Some(("delete", _)) => { - confirm(format!("Really delete {}?", container_id))?; - delete(container).await + if confirm(format!("Really delete {}?", container_id))? { + delete(container).await + } else { + Ok(()) + } }, Some(("start", _)) => { - confirm(format!("Really start {}?", container_id))?; - start(container).await + if confirm(format!("Really start {}?", container_id))? { + start(container).await + } else { + Ok(()) + } }, Some(("stop", matches)) => { - confirm(format!("Really stop {}?", container_id))?; - stop(matches, container).await + if confirm(format!("Really stop {}?", container_id))? { + stop(matches, container).await + } else { + Ok(()) + } }, Some(("exec", matches)) => { - confirm({ - let commands = matches.values_of("commands").unwrap().collect::>(); - format!("Really run '{}' in {}?", commands.join(" "), container_id) - })?; - exec(matches, container).await + let commands = matches.values_of("commands").unwrap().collect::>(); + if confirm(format!("Really run '{}' in {}?", commands.join(" "), container_id))? { + exec(matches, container).await + } else { + Ok(()) + } }, Some(("inspect", _)) => inspect(container).await, Some((other, _)) => Err(anyhow!("Unknown subcommand: {}", other)), -- cgit v1.2.3