commit | 84effd66c053a2103cdf5455cc63a04449caf6af | [log] [tgz] |
---|---|---|
author | Katsu Kawakami <kkawa1570@gmail.com> | Fri Nov 13 00:42:59 2015 -0500 |
committer | Katsu Kawakami <kkawa1570@gmail.com> | Fri Nov 13 00:42:59 2015 -0500 |
tree | 18f1222735060767579334851e36ba4530850f14 | |
parent | 5a6e9038ee543382960523d8038cb25dea193b1c [diff] | |
parent | 8010885266438e627f4f9a275ac19455dfff917c [diff] |
Merge pull request #13 from gwenn/hist Add incremental reverse search
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"