diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 95c3c46..ca5dc00 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,21 @@ use rustyline::error::ReadlineError; use rustyline::Editor; -mod parser; +mod commandline; +use commandline::CommandLine; mod prompt; -fn main() { - match std::fs::read_to_string("/etc/motd") { - Ok(motd) => print!("{}", motd), - Err(_) => {} +fn main() -> Result<(), std::io::Error>{ + if let Ok(motd) = std::fs::read_to_string("/etc/motd") { + print!("{}", motd) } - let prompt = prompt::Prompt::new().unwrap(); - let mut status = None; - - // `()` can be used when no completer is required + // TODO: [completer] `()` can be used when no completer is required let mut rl = Editor::<()>::new(); + let prompt = prompt::Prompt::new()?; + + let mut status = None; // exit status of last command + // map of variables /*if rl.load_history("history.txt").is_err() { println!("No previous history."); @@ -25,7 +26,7 @@ fn main() { Ok(line) => { rl.add_history_entry(line.as_str()); - let cmd = parser::CommandLine::new(&line); + let cmd = CommandLine::new(&line); match cmd.run(&prompt.home, status) { Ok(s) => status = s, Err(e) => eprintln!("{}", e), @@ -47,4 +48,6 @@ fn main() { } //rl.save_history("history.txt").unwrap(); + + Ok(()) } |