| Crates.io | interaction |
| lib.rs | interaction |
| version | 0.3.4 |
| created_at | 2021-01-12 10:33:41.40331+00 |
| updated_at | 2021-01-17 12:23:18.73101+00 |
| description | Interaction is a minimal and a simple readline library for Rust. |
| homepage | https://github.com/odd12258053/interaction |
| repository | https://github.com/odd12258053/interaction |
| max_upload_size | |
| id | 340815 |
| size | 28,448 |
Interaction is a minimal and a simple readline library for Rust.
Add this in your Cargo.toml:
[dependencies]
interaction = "0.3.4"
Or, if you installed cargo-edit, you run this command:
$ cargo add interaction
use interaction::InteractionBuilder;
use std::io;
fn main() {
let history_file = "./.example_history";
let mut inter = InteractionBuilder::new()
.prompt_str(";;>")
.history_limit(5)
.completion(|_input, completions| {
completions.push(b"foo".to_vec());
completions.push(b"bar".to_vec());
})
.load_history(history_file)
.unwrap()
.build();
loop {
match inter.line() {
Ok(input) => {
// write any code.
}
Err(e) if e.kind() == io::ErrorKind::Interrupted => {
inter.save_history(history_file).unwrap();
break;
}
Err(_) => {
break;
}
}
}
}