commit | f9b4f43b8b5d5869fc9cb0e0cbcecaf18d76890b | [log] [tgz] |
---|---|---|
author | Katsu Kawakami <kkawa1570@gmail.com> | Sun Dec 20 12:02:45 2015 -0500 |
committer | Katsu Kawakami <kkawa1570@gmail.com> | Sun Dec 20 12:02:45 2015 -0500 |
tree | 0d7a150c9a9014052e639a87990b7bb678d68467 | |
parent | cba1b09966bce6dae9dabeb7bd49534dff9a89ef [diff] |
Release 0.2.0
Readline implementation in Rust that is based on Antirez' Linenoise
This project uses Cargo and Rust Nightly
cargo build --release
extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; fn main() { let mut rl = Editor::new(); if let Err(_) = rl.load_history("history.txt") { println!("No previous history."); } loop { let readline = rl.readline(">> "); match readline { Ok(line) => { rl.add_history_entry(&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
:
[dependencies] rustyline = "0.1.0"