diff --git a/src/command.rs b/src/command.rs index 4170a4e..64112cd 100644 --- a/src/command.rs +++ b/src/command.rs @@ -18,6 +18,45 @@ pub trait Command { fn spawn(&self) -> ExitCode; } +pub struct CommandSequence { + command: Option>, + next_command: Option>, +} + +impl CommandSequence { + pub fn new() -> Self { + Self { + command: None, + next_command: None, + } + } + + /* + pub fn add(&self, command: &dyn Command) { + if self.command.is_none() { + let my_box = Box::new(command.to_owned()); + self.command = Some(my_box); + } + } + */ +} + +impl Command for CommandSequence { + fn spawn(&self) -> ExitCode { + let mut exit_code = ExitCode::new(0); + + if self.command.is_some() { + exit_code = self.command.as_ref().unwrap().spawn(); + } + + if self.next_command.is_some() { + exit_code = self.next_command.as_ref().unwrap().spawn(); + } + + exit_code + } +} + pub struct UnixProgram { argv: Vec, }