Readline implementation in Rust that is based on Antirez' Linenoise
This project uses Cargo and Rust Nightly
bash
cargo build --release
```rust extern crate rustyline;
use rustyline::error::ReadlineError; use rustyline::Editor;
fn main() { let mut rl = Editor::new(); if let Err() = rl.loadhistory("history.txt") { println!("No previous history."); } loop { let readline = rl.readline(">> "); match readline { Ok(line) => { rl.addhistoryentry(&line); println!("Line: {}", line); }, Err(ReadlineError::Interrupted) => { println!("CTRL-C"); break }, Err(ReadlineError::Eof) => { println!("CTRL-D"); break }, Err(err) => { println!("Error: {:?}", err); break } } } rl.save_history("history.txt").unwrap(); } ```
You can use this package in your project by adding the following
to your Cargo.toml
:
toml
[dependencies]
rustyline = "0.1.0"