A simple utility to prompt users of your CLI app.
extern crate trompt;
use trompt::Trompt;
fn main() {
use std::io::Cursor;
let input = Cursor::new(b"tupac");
let output = Cursor::new(Vec::new());
let username = Trompt::new(input, output)
.required()
.prompt("Username: ");
assert_eq!(username, Ok("tupac".to_string()));
let password = Trompt::stdout()
.silent()
.min_len(8)
.prompt("Password: ");
let input = Cursor::new(b"YES");
let output = Cursor::new(Vec::new());
let confirmed = Trompt::new(input, output)
.confirm("Are you sure [yn]? ");
assert_eq!(confirmed, Ok(true));
}
Trompt |
The state of the prompt that we send to the user. It is general on
any input and output that implement Read and Write
respectively.
|