confirm/
confirm.rs

1use dialoguer::{theme::ColorfulTheme, Confirm};
2
3fn main() {
4    if Confirm::with_theme(&ColorfulTheme::default())
5        .with_prompt("Do you want to continue?")
6        .interact()
7        .unwrap()
8    {
9        println!("Looks like you want to continue");
10    } else {
11        println!("nevermind then :(");
12    }
13
14    if Confirm::with_theme(&ColorfulTheme::default())
15        .with_prompt("Do you really want to continue?")
16        .default(true)
17        .interact()
18        .unwrap()
19    {
20        println!("Looks like you want to continue");
21    } else {
22        println!("nevermind then :(");
23    }
24
25    if Confirm::with_theme(&ColorfulTheme::default())
26        .with_prompt("Do you really really want to continue?")
27        .default(true)
28        .show_default(false)
29        .wait_for_newline(true)
30        .interact()
31        .unwrap()
32    {
33        println!("Looks like you want to continue");
34    } else {
35        println!("nevermind then :(");
36    }
37
38    if Confirm::with_theme(&ColorfulTheme::default())
39        .with_prompt("Do you really really really want to continue?")
40        .wait_for_newline(true)
41        .interact()
42        .unwrap()
43    {
44        println!("Looks like you want to continue");
45    } else {
46        println!("nevermind then :(");
47    }
48
49    match Confirm::with_theme(&ColorfulTheme::default())
50        .with_prompt("Do you really really really really want to continue?")
51        .interact_opt()
52        .unwrap()
53    {
54        Some(true) => println!("Looks like you want to continue"),
55        Some(false) => println!("nevermind then :("),
56        None => println!("Ok, we can start over later"),
57    }
58
59    match Confirm::with_theme(&ColorfulTheme::default())
60        .with_prompt("Do you really really really really really want to continue?")
61        .default(true)
62        .wait_for_newline(true)
63        .interact_opt()
64        .unwrap()
65    {
66        Some(true) => println!("Looks like you want to continue"),
67        Some(false) => println!("nevermind then :("),
68        None => println!("Ok, we can start over later"),
69    }
70}