command : la struct UnixProgram contient désormais un std::process::Command construit à son initialisation à partir d'un argv

This commit is contained in:
Ahurac 2024-04-11 01:35:16 +02:00
parent 2a0f11cca8
commit d7f2de803d

View file

@ -49,20 +49,12 @@ impl Command for CommandSequence {
}
pub struct UnixProgram {
argv: Vec<String>,
command: std::process::Command,
}
impl UnixProgram {
pub fn new(argv: Vec<String>) -> Self {
Self { argv }
}
}
impl Command for UnixProgram {
fn spawn(&self) -> ExitCode {
let mut argv = self.argv.clone();
pub fn new(mut argv: Vec<String>) -> Self {
let program = argv.remove(0);
let mut command = std::process::Command::new(&program);
command.args(argv);
@ -89,7 +81,10 @@ impl Command for UnixProgram {
exit_code
} else {
let message = format!("{}: command not found", &program);
let message = format!(
"{}: command not found",
self.command.get_program().to_str().unwrap()
);
error::print_error(message);
ExitCode::not_found()
}