command : ajout struct
CommandSequence
This commit is contained in:
parent
056d56b348
commit
dc0e63b8e6
1 changed files with 39 additions and 0 deletions
|
@ -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>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue