|
2 | 2 | //! |
3 | 3 | //! This module provides a structured way to execute and manage commands efficiently, |
4 | 4 | //! ensuring controlled failure handling and output management. |
5 | | -
|
| 5 | +#![allow(warnings)] |
6 | 6 | use std::ffi::OsStr; |
7 | 7 | use std::fmt::{Debug, Formatter}; |
8 | 8 | use std::path::Path; |
9 | | -use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio}; |
| 9 | +use std::process::{Child, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio}; |
10 | 10 |
|
11 | 11 | use build_helper::ci::CiEnv; |
12 | 12 | use build_helper::drop_bomb::DropBomb; |
13 | 13 |
|
14 | | -use super::execution_context::ExecutionContext; |
| 14 | +use super::execution_context::{DeferredCommand, ExecutionContext}; |
15 | 15 |
|
16 | 16 | /// What should be done when the command fails. |
17 | 17 | #[derive(Debug, Copy, Clone)] |
@@ -158,6 +158,21 @@ impl BootstrapCommand { |
158 | 158 | exec_ctx.as_ref().run(self, OutputMode::Capture, OutputMode::Print) |
159 | 159 | } |
160 | 160 |
|
| 161 | + /// Spawn the command in background, while capturing and returning all its output. |
| 162 | + #[track_caller] |
| 163 | + pub fn start_capture(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> DeferredCommand { |
| 164 | + exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Capture) |
| 165 | + } |
| 166 | + |
| 167 | + /// Spawn the command in background, while capturing and returning stdout, and printing stderr. |
| 168 | + #[track_caller] |
| 169 | + pub fn start_capture_stdout( |
| 170 | + &mut self, |
| 171 | + exec_ctx: impl AsRef<ExecutionContext>, |
| 172 | + ) -> DeferredCommand { |
| 173 | + exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Print) |
| 174 | + } |
| 175 | + |
161 | 176 | /// Provides access to the stdlib Command inside. |
162 | 177 | /// FIXME: This function should be eventually removed from bootstrap. |
163 | 178 | pub fn as_command_mut(&mut self) -> &mut Command { |
|
0 commit comments