Interaction

Crates.io Crates.io

Interaction is a minimal and a simple readline library for Rust.

Usage

Add this in your Cargo.toml:

toml [dependencies] interaction = "0.3.0"

Or, if you installed cargo-edit, you run this command:

sh $ cargo add interaction

Example

```rust use interaction::InteractionBuilder; use std::io;

fn main() { let historyfile = "./.examplehistory"; let mut inter = InteractionBuilder::new() .promptstr(";;>") .historylimit(5) .completion(|input, completions| { completions.push(b"foo"); completions.push(b"bar"); }) .loadhistory(historyfile) .unwrap() .build(); loop { match inter.line() { Ok(input) => { // write any code. } Err(e) if e.kind() == io::ErrorKind::Interrupted => { inter.savehistory(historyfile).unwrap(); break; } Err() => { break; } } } } ```