| 272 | } |
| 273 | |
| 274 | fn run_external(&self, prev_output: Option<Output>) -> Result<Option<Output>> { |
| 275 | let mut command = Command::new(&self.binary); |
| 276 | command.args(&self.args); |
| 277 | |
| 278 | if prev_output.is_some() { |
| 279 | command.stdin(Stdio::piped()); |
| 280 | } |
| 281 | |
| 282 | let mut child = command |
| 283 | .stdout(Stdio::piped()) |
| 284 | .stderr(Stdio::piped()) |
| 285 | .spawn()?; |
| 286 | |
| 287 | if let Some(prev_output) = prev_output { |
| 288 | if let Some(mut stdin) = child.stdin.take() { |
| 289 | stdin.write_all(&prev_output.stdout)?; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | let output = child.wait_with_output()?; |
| 294 | Ok(Some(output)) |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | fn main() { |