feat: silence progress with --quiet

This commit is contained in:
2026-09-08 14:16:08 +00:00
parent cabbbde438
commit 61f35f5ae4
9 changed files with 67 additions and 45 deletions

View File

@@ -1,7 +1,13 @@
use super::{Argv, Cmd};
fn compose() -> Argv {
Argv::new("docker").arg("compose")
// compose prints its own progress, which --quiet has to ask it to stop
fn compose(quiet: bool) -> Argv {
let argv = Argv::new("docker").arg("compose");
match quiet {
true => argv.flag("--progress", "quiet"),
false => argv,
}
}
// docker compose run --rm, which runs the image's entrypoint and so fixes up the
@@ -22,7 +28,7 @@ impl Run {
impl Cmd for Run {
fn argv(&self) -> Argv {
compose()
compose(false)
.arg("run")
.arg("--rm")
.arg(&self.service)
@@ -35,7 +41,7 @@ pub struct Config;
impl Cmd for Config {
fn argv(&self) -> Argv {
compose().arg("config").flag("--format", "json")
compose(false).arg("config").flag("--format", "json")
}
}
@@ -54,39 +60,37 @@ impl Ps {
impl Cmd for Ps {
fn argv(&self) -> Argv {
compose().arg("ps").arg("--quiet").arg(&self.service)
compose(false).arg("ps").arg("--quiet").arg(&self.service)
}
}
pub struct Up;
pub struct Up {
pub quiet: bool,
}
impl Cmd for Up {
fn argv(&self) -> Argv {
compose().arg("up").arg("--detach")
compose(self.quiet).arg("up").arg("--detach")
}
}
pub struct Start {
service: String,
pub struct Start<'a> {
pub service: &'a str,
pub quiet: bool,
}
impl Start {
pub fn service(service: &str) -> Self {
Self {
service: service.to_string(),
}
}
}
impl Cmd for Start {
impl Cmd for Start<'_> {
fn argv(&self) -> Argv {
compose().arg("start").arg(&self.service)
compose(self.quiet).arg("start").arg(self.service)
}
}
pub struct Stop;
pub struct Stop {
pub quiet: bool,
}
impl Cmd for Stop {
fn argv(&self) -> Argv {
compose().arg("stop")
compose(self.quiet).arg("stop")
}
}