1use cli_prompts::{
2 prompts::{Confirmation, Input, Multiselect, Selection},
3 DisplayPrompt,
4};
5
6#[derive(Debug)]
7enum CarModel {
8 Audi,
9 BMW,
10 Chevrolet,
11}
12
13fn car_to_string(car: &CarModel) -> String {
14 match car {
15 CarModel::Audi => "Audi A3".into(),
16 CarModel::BMW => "BMW X5".into(),
17 CarModel::Chevrolet => "Chevrolet 11".into(),
18 }
19}
20
21fn main() {
22 let desserts = [
23 "Tiramisu",
24 "Cheesecake",
25 "Brownee",
26 "Cookie",
27 "Jelly",
28 "Chupa-Chups",
29 "Pudding",
30 ];
31 let subjects = [
32 "Physics",
33 "Math",
34 "Polish",
35 "English",
36 "Sport",
37 "Geography",
38 "History",
39 ];
40 let cars = [CarModel::Audi, CarModel::BMW, CarModel::Chevrolet];
41
42 let input_prompt = Input::new("Enter your name", |s| Ok(s.to_string()))
43 .default_value("John")
44 .help_message("Please provide your real name");
45 let confirmation = Confirmation::new("Do you want a cup of coffee?").default_positive(true);
46 let dessert_selection = Selection::new("Your favoite dessert", desserts.into_iter());
47 let car_selection =
48 Selection::new_with_transformation("Your car model", cars.into_iter(), car_to_string);
49 let subjects_selection =
50 Multiselect::new("What are your favourite subjects", subjects.into_iter());
51
52 let name = input_prompt.display();
53 let is_coffee = confirmation.display();
54 let dessert = dessert_selection.display();
55 let car = car_selection.display();
56 let subjects = subjects_selection.display();
57
58 println!("Name: {:?}", name);
59 println!("Is coffee: {:?}", is_coffee);
60 println!("Dessert: {:?}", dessert);
61 println!("Car: {:?}", car);
62 println!("Subjects: {:?}", subjects);
63}