Make REPL friendlier

This commit is contained in:
greg 2017-02-02 11:19:29 -08:00
parent 039022bfc5
commit 8ff1c632c2

View File

@ -136,7 +136,7 @@ impl Repl {
} }
fn run(&mut self) { fn run(&mut self) {
use linefeed::ReadResult::*; use linefeed::ReadResult::*;
println!("Schala v 0.02"); println!("MetaInterpreter v 0.05");
loop { loop {
match self.reader.read_line() { match self.reader.read_line() {
Err(e) => { Err(e) => {
@ -203,9 +203,11 @@ impl Repl {
}, },
Some(&"next") => { Some(&"next") => {
self.current_language_index = (self.current_language_index + 1) % self.languages.len(); self.current_language_index = (self.current_language_index + 1) % self.languages.len();
println!("Switching to {}", self.languages[self.current_language_index].get_language_name());
} }
Some(&"prev") | Some(&"previous") => { Some(&"prev") | Some(&"previous") => {
self.current_language_index = if self.current_language_index == 0 { self.languages.len() - 1 } else { self.current_language_index - 1 } self.current_language_index = if self.current_language_index == 0 { self.languages.len() - 1 } else { self.current_language_index - 1 };
println!("Switching to {}", self.languages[self.current_language_index].get_language_name());
}, },
Some(e) => println!("Bad `lang` argument: {}", e), Some(e) => println!("Bad `lang` argument: {}", e),
None => println!("`lang` - valid arguments `show`, `next`, `prev`|`previous`"), None => println!("`lang` - valid arguments `show`, `next`, `prev`|`previous`"),