[−][src]Crate interaction
Interaction is a minimal and a simple readline library.
Features
- Single line editing mode
- Multi line editing mode
- Key bindings
- History
- Completion
Example
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; } } } }
Structs
History | The struct is to management the history of command line. |
Interaction | A instance of interaction. |
InteractionBuilder | Builder of Interaction. |
Type Definitions
Completion | The type is a callback for completion. |