A [Rust] library for simple (usually command-line) user interaction.
A program that accepts a newline-separated list of items on stdin
, presents a UI to the user (directly on /dev/tty
if it's a CLI; can also be a GUI), and outputs the selected item on stdout
.
You should let the users of your application pick their own favorite tool as a config option.
I propose the $MENU
environment variable, like $EDITOR
, as a place to look for user preference.
```rust extern crate interactor;
use std::io::Write; use interactor::*;
fn main() { let readresult = readfromtty(|buf, b, tty| { tty.write(&format!("({:?} | {})\n", buf, b).intobytes()); }, false, false).unwrap(); println!("Read: {}", String::fromutf8(readresult).unwrap());
let chosen_ext = pick_from_list(default_menu_cmd().as_mut(), &["first", "second"], "Selection: ").unwrap();
println!("Congratulations, you chose '{}'!!", chosen_ext);
} ```
This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE
file or unlicense.org.