feat: finish docker cli
Implement wanted functionality for docker subcommands.
This commit is contained in:
parent
9c34f6ff59
commit
907740fc5a
|
@ -1,5 +1,9 @@
|
|||
use super::DockerCommand;
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn stop_all() -> Result<()> {
|
||||
todo!()
|
||||
let running_containers = DockerCommand::docker().args("ps -q").stdout()?;
|
||||
DockerCommand::docker()
|
||||
.args(&format!("stop {running_containers}"))
|
||||
.spawn_wait()
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@ impl DockerCommand {
|
|||
self
|
||||
}
|
||||
|
||||
fn stdout(mut self) -> Result<String> {
|
||||
Ok(String::from_utf8(self.command.output()?.stdout)?)
|
||||
}
|
||||
|
||||
fn spawn_wait(mut self) -> Result<()> {
|
||||
self.command
|
||||
.spawn()
|
||||
.context("failed spawning command")?
|
||||
.wait()
|
||||
.context("failed while waiting")?;
|
||||
self.command.spawn()?.wait()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue