diff options
Diffstat (limited to 'src/parser.rs')
-rw-r--r-- | src/parser.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/parser.rs b/src/parser.rs index af4aed4..a96b679 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,14 +1,45 @@ +use std::io::Error; +use std::path::PathBuf; +use std::process::ExitStatus; + // > overwrite // >> append // | pipe +// : on prev cmd any // && on prev cmd okay // || on prev cmd fail -pub mod command; - +mod command; use command::*; +pub struct CommandLine(Vec<CommandInfo>); + +impl CommandLine { + pub fn new(line: &str) -> Self { + let split = line.split(':'); + let mut v = CommandLine(Vec::new()); + for x in split { + v.0.push(tokenize(x)); + } + v + } + + pub fn run( + &self, + home: &PathBuf, + mut status: Option<ExitStatus>, + ) -> Result<Option<ExitStatus>, Error> { + for cmd in &self.0 { + match cmd.run(&home, &status)? { + RunResult::Command(s) => status = Some(s), + RunResult::Builtin => {} + } + } + Ok(status) + } +} + enum TokenType { Argument, StdoutFileOverwrite, |