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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user