Created
July 26, 2018 12:12
-
-
Save mykhailokrainik/d373411b5ff6a1b4f5d5622d02bc1497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! ```cargo | |
//! [dependencies] | |
//! dialoguer = "*" | |
//! indicatif = "*" | |
//! ``` | |
extern crate dialoguer; | |
extern crate indicatif; | |
use dialoguer::Select; | |
fn main() { | |
println!("To be or not to be?"); | |
let selections = &["Yes", "No"]; | |
let selection = Select::new() | |
.default(0) | |
.items(&selections[..]) | |
.interact() | |
.unwrap(); | |
let bar = indicatif::ProgressBar::new(50); | |
bar.set_style(indicatif::ProgressStyle::default_bar() | |
.template("Processing... {bar:30}")); | |
for i in 0..50 { | |
bar.inc(1); | |
std::thread::sleep_ms(50); | |
} | |
bar.finish_and_clear(); | |
println!("What do you mean by {:?}?", selections[selection]); | |
println!( | |
"You are supposed to answer either {:?} or {:?}", | |
"to be", "not to be" | |
); | |
} |
Author
mykhailokrainik
commented
Jul 26, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment