diff --git a/src/command/command_builder.rs b/src/command/command_builder.rs index b7e88be..6b409bb 100644 --- a/src/command/command_builder.rs +++ b/src/command/command_builder.rs @@ -1,3 +1,4 @@ +use super::builtin::Builtin; use super::unix_program::UnixProgram; use super::Command; @@ -15,8 +16,15 @@ impl CommandBuilder { self } - pub fn build(&self) -> impl Command { - let command = UnixProgram::new(&self.argv); + pub fn build(&self) -> Box { + let builtin = Builtin::new(&self.argv); + let command: Box; + + if builtin.is_err() { + command = Box::from(UnixProgram::new(&self.argv)); + } else { + command = Box::from(builtin.unwrap()); + } command } diff --git a/src/command/command_sequence.rs b/src/command/command_sequence.rs index 443d7c9..df61e36 100644 --- a/src/command/command_sequence.rs +++ b/src/command/command_sequence.rs @@ -7,14 +7,14 @@ pub struct CommandSequence { } impl CommandSequence { - pub fn new(command: impl Command + 'static) -> Self { + pub fn new(command: Box) -> Self { Self { - command: Box::new(command), + command, next_command: None, } } - pub fn add(&mut self, command: impl Command + 'static) { + pub fn add(&mut self, command: Box) { if self.next_command.is_none() { self.next_command = Some(Box::new(Self::new(command))); } else { diff --git a/src/command/mod.rs b/src/command/mod.rs index c369d2a..da38895 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,3 +1,4 @@ +pub mod builtin; pub mod command_builder; pub mod command_sequence; pub mod unix_program;