commit | 7592209b6bb18ceffd4150c9550d1a300635f1c8 | [log] [tgz] |
---|---|---|
author | Katsu Kawakami <kkawa1570@gmail.com> | Fri Mar 25 00:27:52 2016 -0400 |
committer | Katsu Kawakami <kkawa1570@gmail.com> | Fri Mar 25 00:27:52 2016 -0400 |
tree | d8e5648738cc5d3a5bce28c4353199e387692d0e | |
parent | 4694009168917336ae369cf111fd9f0eba307b3e [diff] | |
parent | d10a454c603ddd2908a56453459648a21c6afc1b [diff] |
Merge pull request #26 from saghm/master fix for encode_ut8 returning iterator
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.2.1"