pub fn read_from_tty<F>(
byte_callback: F,
run_before_input: bool,
run_after_input: bool,
) -> Result<Vec<u8>>Examples found in repository?
examples/demo.rs (lines 9-11)
6fn main() {
7 println!("Interactor demo. Type something:");
8
9 let read_result = read_from_tty(|buf, b, tty| {
10 tty.write(&format!("({:?} | {})\n", buf, b).into_bytes());
11 }, false, false).unwrap();
12 println!("Read: {}", String::from_utf8(read_result).unwrap());
13
14 let chosen_ext = pick_from_list(default_menu_cmd().as_mut(), &["first", "second"], "").unwrap();
15 println!("Congratulations, you chose '{}'!!", chosen_ext);
16
17 let chosen_file = pick_file(|| default_menu_cmd(), std::env::current_dir().unwrap()).unwrap();
18 println!("Congratulations, you chose '{}'!!", chosen_file.display());
19
20 let chosen_int = pick_from_list(None, &["first", "second"], "Selection: ").unwrap();
21 println!("Congratulations, you chose '{}'!!", chosen_int);
22}