feat: let docker compose find its own file
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use anyhow::{Context, Result};
|
||||
use std::{
|
||||
env,
|
||||
fmt::Display,
|
||||
process::{Child, Command, Stdio},
|
||||
};
|
||||
@@ -27,11 +26,6 @@ impl From<&[String]> for Args {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_compose_file() -> Result<String> {
|
||||
let cf = env::var("COMPOSE_FILE")?;
|
||||
Ok(cf)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CommandBuilder {
|
||||
args: Vec<String>,
|
||||
@@ -49,9 +43,7 @@ impl CommandBuilder {
|
||||
}
|
||||
|
||||
pub fn docker_compose() -> Self {
|
||||
let cf =
|
||||
get_compose_file().unwrap_or_else(|_| "docker/local/docker-compose.yaml".to_string());
|
||||
Self::default().args("docker compose -f").args(&cf)
|
||||
Self::default().args("docker compose")
|
||||
}
|
||||
|
||||
pub fn args<T>(mut self, args: T) -> Self
|
||||
|
||||
@@ -24,13 +24,6 @@ pub fn ps() -> Result<()> {
|
||||
CommandBuilder::docker_compose().args("ps").exec()
|
||||
}
|
||||
|
||||
/// Start containers via `docker compose start`. Optionally pass containers to be started.
|
||||
/// ```
|
||||
/// # use ahab::scripts::docker_compose::start;
|
||||
/// start(None);
|
||||
/// ```
|
||||
/// is roughly the same as
|
||||
/// `docker compose --env-file ./.env -f docker/local/docker-compose.yaml up start`
|
||||
pub fn start(containers: Option<&str>) -> Result<()> {
|
||||
let args = format!("start {}", containers.unwrap_or(""));
|
||||
CommandBuilder::docker_compose().args(&args).exec()
|
||||
|
||||
Reference in New Issue
Block a user