multi_select/
multi_select.rs1use dialoguer_ext::{theme::ColorfulTheme, MultiSelect};
2
3fn main() {
4 let multiselected = &[
5 "Ice Cream",
6 "Vanilla Cupcake",
7 "Chocolate Muffin",
8 "A Pile of sweet, sweet mustard",
9 ];
10 let defaults = &[false, false, true, false];
11 let selections = MultiSelect::with_theme(&ColorfulTheme::default())
12 .with_prompt("Pick your food")
13 .items(&multiselected[..])
14 .defaults(&defaults[..])
15 .interact()
16 .unwrap();
17
18 if selections.is_empty() {
19 println!("You did not select anything :(");
20 } else {
21 println!("You selected these things:");
22 for selection in selections {
23 println!(" {}", multiselected[selection]);
24 }
25 }
26
27 let selections = MultiSelect::with_theme(&ColorfulTheme::default())
28 .with_prompt("Pick your food")
29 .items(&multiselected[..])
30 .defaults(&defaults[..])
31 .max_length(2)
32 .interact()
33 .unwrap();
34 if selections.is_empty() {
35 println!("You did not select anything :(");
36 } else {
37 println!("You selected these things:");
38 for selection in selections {
39 println!(" {}", multiselected[selection]);
40 }
41 }
42}