diff --git a/src/control.rs b/src/control.rs index 56466cd..74e2a53 100644 --- a/src/control.rs +++ b/src/control.rs @@ -1,5 +1,6 @@ -use crate::command::{Command, ExitCode, UnixProgram}; +use crate::command::{Command, ExitCode}; use crate::interface::{get_user_input, print_prompt}; +use crate::parser::parse_command_line; fn exit(code: &ExitCode) { let code = i32::from(code.get()); @@ -17,15 +18,9 @@ pub fn run() { if user_input.is_some() { let user_input = user_input.unwrap(); + let command_sequence = parse_command_line(user_input); - let argv: Vec = user_input - .split_whitespace() - .map(|s| s.to_string()) - .collect(); - - if !argv.is_empty() { - current_exit_code = UnixProgram::new().argv(argv).spawn(); - } + current_exit_code = command_sequence.spawn(); } else { println!(); exit(¤t_exit_code); diff --git a/src/main.rs b/src/main.rs index 9aa2dce..fd3fe96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod command; mod control; mod error; mod interface; +mod parser; fn main() { control::run();