diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-16 10:32:56 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-03-16 10:32:56 +0100 |
commit | 91adbd08d2b781cd13bac49bce5fd87aa1908767 (patch) | |
tree | ce00925d2b8103dd753641196dd9a921ffc75f18 /src | |
parent | 040b19ea29212375d5cb308791bacd77f27ab3b9 (diff) |
Fix: Check return value of confirmation prompt
This is an embarrassing bug. :-/
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/endpoint_container.rs | 32 |
1 files 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<EndpointName>, 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::<Vec<&str>>(); - format!("Really run '{}' in {}?", commands.join(" "), container_id) - })?; - exec(matches, container).await + let commands = matches.values_of("commands").unwrap().collect::<Vec<&str>>(); + 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)), |