diff --git a/crates/oyster_runtime/src/pipeline.rs b/crates/oyster_runtime/src/pipeline.rs index ae4a62c..f2ec863 100644 --- a/crates/oyster_runtime/src/pipeline.rs +++ b/crates/oyster_runtime/src/pipeline.rs @@ -34,6 +34,23 @@ struct PreparedCommand<'a> { } impl<'a> PreparedCommand<'a> { + /// Create a new PreparedCommand. + fn new(command: &'a ast::Command) -> Self { + let mut words = WordBuilder(command.0.iter()); + let cmd = words.next().expect("words need to have >1 parts"); + let args = words; + let redirect = command.1; + + PreparedCommand { + cmd, + args, + redirect, + stdin: None, + stdout: None, + stderr: None, + } + } + /// Run this command with the given context. fn spawn(self, pgid: &mut Pid) -> Result { let args = self.args.map(|w| match w { @@ -92,24 +109,6 @@ impl<'a> PreparedCommand<'a> { } } -impl<'a> From<&'a ast::Command<'a>> for PreparedCommand<'a> { - fn from(command: &'a ast::Command<'a>) -> Self { - let mut words = WordBuilder(command.0.iter()); - let cmd = words.next().expect("words need to have >1 parts"); - let args = words; - let redirect = command.1; - - PreparedCommand { - cmd, - args, - redirect, - stdin: None, - stdout: None, - stderr: None, - } - } -} - impl Shell { pub(crate) fn run_pipeline( &mut self, @@ -117,7 +116,7 @@ impl Shell { ) -> Result { let mut pgid = Pid::from_raw(0); let status = (|| { - let mut cmds = pipeline.0.iter().map(PreparedCommand::from); + let mut cmds = pipeline.0.iter().map(PreparedCommand::new); let mut last_cmd = cmds.next().expect("pipelines need to have >1 commands"); for mut cmd in cmds {