Browse Source

feat: implement basic read-eval-print loop

main
fdai7381 2 years ago
parent
commit
e6d0536964
  1. 31
      src/main.rs

31
src/main.rs

@ -1,3 +1,30 @@
fn main() {
println!("Hello, world!");
use rustyline::error::ReadlineError;
use rustyline::{Editor, Result};
fn main() -> Result<()> {
let mut rl = Editor::<()>::new()?;
loop {
let readline = rl.readline("» ");
match readline {
Ok(line) => {
println!("Line: {}", line);
},
Err(ReadlineError::Interrupted) => {
println!("CTRL-C");
break
},
Err(ReadlineError::Eof) => {
println!("CTRL-D");
break
},
Err(err) => {
println!("Error: {:?}", err);
break
}
}
}
Ok(())
} }
Loading…
Cancel
Save