From f48a79df4e3cf3110bb341df9da446033ad3d6d3 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Wed, 10 Apr 2024 10:03:29 +0200 Subject: [PATCH] src : affichage du message d'erreur en cas de commande introuvable --- src/command.rs | 5 ++++- src/main.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/command.rs b/src/command.rs index 1659407..8d2db2f 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,3 +1,5 @@ +use crate::error; + pub struct ExitCode { exit_code: u8, } @@ -36,7 +38,7 @@ impl Command for UnixProgram { let mut argv = self.argv.clone(); let program = argv.remove(0); - let mut command = std::process::Command::new(program); + let mut command = std::process::Command::new(&program); command.args(argv); let handle = command.spawn(); @@ -56,6 +58,7 @@ impl Command for UnixProgram { exit_code } else { + error::print_error(format!("{}: command not found", program)); ExitCode::new(127) } } diff --git a/src/main.rs b/src/main.rs index e0c4797..9aa2dce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ mod command; mod control; +mod error; mod interface; fn main() {