-
Notifications
You must be signed in to change notification settings - Fork 5
/
multiselect.rs
27 lines (26 loc) · 890 Bytes
/
multiselect.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use demand::{DemandOption, MultiSelect};
fn main() {
let multiselect = MultiSelect::new("Toppings")
.description("Select your toppings")
.min(1)
.max(4)
.filterable(true)
.option(DemandOption::new("Lettuce").selected(true))
.option(DemandOption::new("Tomatoes").selected(true))
.option(DemandOption::new("Charm Sauce"))
.option(DemandOption::new("Jalapenos").label("Jalapeños"))
.option(DemandOption::new("Cheese"))
.option(DemandOption::new("Vegan Cheese"))
.option(DemandOption::new("Nutella"));
match multiselect.run() {
Ok(toppings) => toppings,
Err(e) => {
if e.kind() == std::io::ErrorKind::Interrupted {
println!("{}", e);
return;
} else {
panic!("Error: {}", e);
}
}
};
}