aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/command.rs
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-15 00:26:16 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-15 01:08:28 +0200
commit18522122f1238d7200a9c4bcc696e707385bcbb1 (patch)
treeff2ea1a90c9098b43fd477c24725383707d19a2e /xtask/src/command.rs
parentfa92d8abe7810c8a32a37be49f162b795c226f4d (diff)
xtask: forward globals through the chain and add stderr-inheritance flag
Diffstat (limited to 'xtask/src/command.rs')
-rw-r--r--xtask/src/command.rs19
1 files changed, 17 insertions, 2 deletions
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<OutputMode> 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<RunResult> {
+pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::Result<RunResult> {
let command_display = command.executable();
let args = command.args();
@@ -425,7 +440,7 @@ pub fn run_command(command: &CargoCommand) -> anyhow::Result<RunResult> {
let result = Command::new(command.executable())
.args(command.args())
.stdout(Stdio::piped())
- .stderr(Stdio::piped())
+ .stderr(stderr_mode)
.output()?;
let exit_status = result.status;