From 18522122f1238d7200a9c4bcc696e707385bcbb1 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sat, 15 Apr 2023 00:26:16 +0200 Subject: xtask: forward globals through the chain and add stderr-inheritance flag --- xtask/src/command.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'xtask/src/command.rs') diff --git a/xtask/src/command.rs b/xtask/src/command.rs index 8a2e99b..9fa5378 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -13,6 +13,21 @@ pub enum BuildMode { Debug, } +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum OutputMode { + PipedAndCollected, + Inherited, +} + +impl From for Stdio { + fn from(value: OutputMode) -> Self { + match value { + OutputMode::PipedAndCollected => Stdio::piped(), + OutputMode::Inherited => Stdio::inherit(), + } + } +} + #[derive(Debug)] pub enum CargoCommand<'a> { // For future embedded-ci @@ -414,7 +429,7 @@ impl fmt::Display for BuildMode { } } -pub fn run_command(command: &CargoCommand) -> anyhow::Result { +pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::Result { let command_display = command.executable(); let args = command.args(); @@ -425,7 +440,7 @@ pub fn run_command(command: &CargoCommand) -> anyhow::Result { let result = Command::new(command.executable()) .args(command.args()) .stdout(Stdio::piped()) - .stderr(Stdio::piped()) + .stderr(stderr_mode) .output()?; let exit_status = result.status; -- cgit v1.2.3