MCPcopy Create free account
hub / github.com/corrode/write-yourself-a-shell / run_external

Method run_external

examples/block5.rs:274–295  ·  view source on GitHub ↗
(&self, prev_output: Option<Output>)

Source from the content-addressed store, hash-verified

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
298fn main() {

Callers 1

runMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected