diff --git a/src/main.rs b/src/main.rs index e7a11a9..ab28964 100644 --- a/src/main.rs +++ b/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(()) +} \ No newline at end of file