@@ -13,19 +13,23 @@ pub enum BehaviorOnFailure {
1313 Ignore ,
1414}
1515
16- /// How should the output of the command be handled (whether it should be captured or printed).
16+ /// How should the output of a specific stream of the command (stdout/stderr) be handled
17+ /// (whether it should be captured or printed).
1718#[ derive( Debug , Copy , Clone ) ]
1819pub enum OutputMode {
19- /// Prints the stdout/stderr of the command to stdout/stderr of bootstrap (by inheriting these
20- /// streams).
21- /// Corresponds to calling `cmd.status()`.
20+ /// Prints the stream by inheriting it from the bootstrap process.
2221 Print ,
23- /// Captures the stdout and stderr of the command into memory.
24- /// Corresponds to calling `cmd.output()`.
25- CaptureAll ,
26- /// Captures the stdout of the command into memory, inherits stderr.
27- /// Corresponds to calling `cmd.output()`.
28- CaptureStdout ,
22+ /// Captures the stream into memory.
23+ Capture ,
24+ }
25+
26+ impl OutputMode {
27+ pub fn captures ( & self ) -> bool {
28+ match self {
29+ OutputMode :: Print => false ,
30+ OutputMode :: Capture => true ,
31+ }
32+ }
2933}
3034
3135/// Wrapper around `std::process::Command`.
@@ -45,7 +49,8 @@ pub enum OutputMode {
4549pub struct BootstrapCommand {
4650 pub command : Command ,
4751 pub failure_behavior : BehaviorOnFailure ,
48- pub output_mode : OutputMode ,
52+ pub stdout : OutputMode ,
53+ pub stderr : OutputMode ,
4954 // Run the command even during dry run
5055 pub run_always : bool ,
5156}
@@ -113,14 +118,14 @@ impl BootstrapCommand {
113118 self
114119 }
115120
116- /// Capture the output of the command, do not print it.
121+ /// Capture all output of the command, do not print it.
117122 pub fn capture ( self ) -> Self {
118- Self { output_mode : OutputMode :: CaptureAll , ..self }
123+ Self { stdout : OutputMode :: Capture , stderr : OutputMode :: Capture , ..self }
119124 }
120125
121126 /// Capture stdout of the command, do not print it.
122127 pub fn capture_stdout ( self ) -> Self {
123- Self { output_mode : OutputMode :: CaptureStdout , ..self }
128+ Self { stdout : OutputMode :: Capture , ..self }
124129 }
125130}
126131
@@ -137,7 +142,8 @@ impl From<Command> for BootstrapCommand {
137142 Self {
138143 command,
139144 failure_behavior : BehaviorOnFailure :: Exit ,
140- output_mode : OutputMode :: Print ,
145+ stdout : OutputMode :: Print ,
146+ stderr : OutputMode :: Print ,
141147 run_always : false ,
142148 }
143149 }
0 commit comments