feat: custom command builder

Implemented custom command builder with nicer api suited for my needs.
Also returned error if there are no containers in
`scripts::postgres::get_containers`.
This commit is contained in:
2023-06-02 17:18:25 +02:00
parent e3306c494d
commit 316b37cd05
7 changed files with 132 additions and 87 deletions

View File

@@ -1,14 +1,15 @@
use super::DockerCommand;
use anyhow::Result;
use crate::command_builder::CommandBuilder;
pub fn stop_all() -> Result<()> {
let running_containers = DockerCommand::docker().args("ps -q").stdout()?;
let running_containers = CommandBuilder::docker().args("ps -q").exec_get_stdout()?;
if running_containers.is_empty() {
return Ok(());
}
DockerCommand::docker()
CommandBuilder::docker()
.args(&format!("stop {running_containers}"))
.spawn_wait()
.exec()
}