reedline/examples/basic.rs
perlindgren 835d2e9f25
examples updated (#493)
Puts the minimal examples from the documentation as separate example executables to play around with
2022-10-16 22:13:55 +02:00

27 lines
786 B
Rust

// Create a default reedline object to handle user input
// cargo run --example basic
//
// You can browse the local (non persistent) history using Up/Down or Ctrl n/p.
use reedline::{DefaultPrompt, Reedline, Signal};
use std::io;
fn main() -> io::Result<()> {
// Create a new Reedline engine with a local History that is not synchronized to a file.
let mut line_editor = Reedline::create();
let prompt = DefaultPrompt::default();
loop {
let sig = line_editor.read_line(&prompt)?;
match sig {
Signal::Success(buffer) => {
println!("We processed: {}", buffer);
}
Signal::CtrlD | Signal::CtrlC => {
println!("\nAborted!");
break Ok(());
}
}
}
}