From aec7afb274ff9774b9787bdd9ad7ce38906600aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Tue, 8 Sep 2026 09:53:38 +0000 Subject: [PATCH] feat: hand back the command's exit code --- src/command_builder.rs | 14 ++++++++++++++ src/scripts/docker_compose.rs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/command_builder.rs b/src/command_builder.rs index 3eaf0c9..96fe2c4 100644 --- a/src/command_builder.rs +++ b/src/command_builder.rs @@ -1,6 +1,7 @@ use anyhow::{Context, Result, bail}; use std::{ fmt::Display, + os::unix::process::CommandExt, process::{Child, Command, ExitStatus, Stdio}, sync::OnceLock, }; @@ -83,6 +84,19 @@ impl CommandBuilder { check(&shown, status) } + // replaces this process, so the command's exit code and signals become ours + pub fn exec_replace(self) -> Result<()> { + if options().dry_run { + eprintln!("would run `{self}`"); + return Ok(()); + } + + let shown = self.to_string(); + let error = self.build()?.exec(); + + Err(error).with_context(|| format!("running `{shown}`")) + } + pub fn spawn(self) -> Result { Ok(self.build()?.spawn()?) } diff --git a/src/scripts/docker_compose.rs b/src/scripts/docker_compose.rs index 763f53b..c80a1d8 100644 --- a/src/scripts/docker_compose.rs +++ b/src/scripts/docker_compose.rs @@ -15,7 +15,7 @@ pub fn run(service: &str, rest: &[String]) -> Result<()> { .args("run --rm") .arg(service) .args(rest) - .exec() + .exec_replace() } pub fn exec(service: &str, rest: &[String]) -> Result<()> {