command : ajout struct CommandSequence

This commit is contained in:
Ahurac 2024-04-10 12:31:57 +02:00
parent 056d56b348
commit dc0e63b8e6

View file

@ -18,6 +18,45 @@ pub trait Command {
fn spawn(&self) -> ExitCode; fn spawn(&self) -> ExitCode;
} }
pub struct CommandSequence {
command: Option<Box<dyn Command>>,
next_command: Option<Box<dyn Command>>,
}
impl CommandSequence {
pub fn new() -> Self {
Self {
command: None,
next_command: None,
}
}
/*
pub fn add(&self, command: &dyn Command) {
if self.command.is_none() {
let my_box = Box::new(command.to_owned());
self.command = Some(my_box);
}
}
*/
}
impl Command for CommandSequence {
fn spawn(&self) -> ExitCode {
let mut exit_code = ExitCode::new(0);
if self.command.is_some() {
exit_code = self.command.as_ref().unwrap().spawn();
}
if self.next_command.is_some() {
exit_code = self.next_command.as_ref().unwrap().spawn();
}
exit_code
}
}
pub struct UnixProgram { pub struct UnixProgram {
argv: Vec<String>, argv: Vec<String>,
} }