main : inclusion du module parser ; control : utilisation de la nouvelle structure

This commit is contained in:
Ahurac 2024-04-10 12:32:32 +02:00
parent dc0e63b8e6
commit a3b2f3da74
2 changed files with 5 additions and 9 deletions

View file

@ -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<String> = 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(&current_exit_code);

View file

@ -2,6 +2,7 @@ mod command;
mod control;
mod error;
mod interface;
mod parser;
fn main() {
control::run();