diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-07 20:05:07 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-07 21:50:29 +0100 |
commit | b1cbb697325f4acc9a6d4c77f16702f6f319f244 (patch) | |
tree | 6cd2b41e2619cb6b176cdf30a6d47f25426253ce /src/commands | |
parent | 0819cd678b40051e1ac6022dfdc57e1690544628 (diff) |
Implement container start subcommand
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/endpoint.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/commands/endpoint.rs b/src/commands/endpoint.rs index ec5b2ef..14a4927 100644 --- a/src/commands/endpoint.rs +++ b/src/commands/endpoint.rs @@ -191,6 +191,7 @@ async fn container(endpoint_names: Vec<String>, Some(("top", matches)) => container_top(matches, relevant_endpoint, container_id).await, Some(("kill", matches)) => container_kill(matches, relevant_endpoint, container_id).await, Some(("delete", _)) => container_delete(relevant_endpoint, container_id).await, + Some(("start", _)) => container_start(relevant_endpoint, container_id).await, Some((other, _)) => Err(anyhow!("Unknown subcommand: {}", other)), None => Err(anyhow!("No subcommand")), } @@ -252,6 +253,22 @@ async fn container_delete( .map_err(Error::from) } +async fn container_start( + endpoint: &Endpoint, + container_id: &str, +) -> Result<()> { + let prompt = format!("Really start {}?", container_id); + dialoguer::Confirm::new().with_prompt(prompt).interact()?; + + endpoint + .get_container_by_id(container_id) + .await? + .ok_or_else(|| anyhow!("Cannot find container {} on {}", container_id, endpoint.name()))? + .start() + .await + .map_err(Error::from) +} + async fn containers(endpoint_names: Vec<String>, matches: &ArgMatches, |