From a3b2f3da7411691154321ea1ec64df3ac4813457 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Wed, 10 Apr 2024 12:32:32 +0200 Subject: [PATCH] main : inclusion du module `parser` ; `control` : utilisation de la nouvelle structure --- src/control.rs | 13 ++++--------- src/main.rs | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) 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();