mirror of
https://github.com/nushell/reedline.git
synced 2024-10-27 01:45:51 +03:00
e1366260c1
* make multiline prompt color configurable * remove unnused use statements * minor comment update * Clippy fix new lints from rust 1.67 * Cargo fmt --------- Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
27 lines
784 B
Rust
27 lines
784 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(());
|
|
}
|
|
}
|
|
}
|
|
}
|