Skip to content

Instantly share code, notes, and snippets.

@mykhailokrainik
Created July 26, 2018 12:12
Show Gist options
  • Save mykhailokrainik/d373411b5ff6a1b4f5d5622d02bc1497 to your computer and use it in GitHub Desktop.
Save mykhailokrainik/d373411b5ff6a1b4f5d5622d02bc1497 to your computer and use it in GitHub Desktop.
//! ```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"
);
}
@mykhailokrainik
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment