showcase/
showcase.rs

1use derive_wizard::Wizard;
2
3#[derive(Debug, Wizard)]
4#[allow(unused)]
5struct ShowCase {
6    // String types - defaults to 'input'
7    #[prompt("Enter your name:")]
8    name: String,
9
10    // Override with password question type
11    #[prompt("Enter your password:")]
12    #[mask]
13    password: String,
14
15    // Long text with multiline editor
16    #[prompt("Enter a bio:")]
17    #[multiline]
18    bio: String,
19
20    // Bool type - defaults to 'confirm'
21    #[prompt("Do you agree to the terms?")]
22    agree: bool,
23
24    // Integer types - defaults to 'int'
25    #[prompt("Enter your age (i32):")]
26    #[min(0)]
27    #[max(150)]
28    age: i32,
29
30    // Float types - defaults to 'float'
31    #[prompt("Enter your height in meters (f64):")]
32    #[min(0.3)]
33    #[max(3.0)]
34    height: f64,
35
36    #[prompt("Enter a decimal number (f32):")]
37    #[min(0.0)]
38    #[max(100.0)]
39    decimal: f32,
40
41    #[prompt("Enter your gender")]
42    gender: Gender,
43}
44
45#[derive(Debug, Wizard)]
46#[allow(unused)]
47enum Gender {
48    Male,
49    Female,
50    Other(#[prompt("Please specify:")] String),
51}
52
53fn main() {
54    println!("=== Derive Wizard Showcase ===");
55    println!("Demonstrating all major field types and attributes");
56    println!();
57
58    #[cfg(feature = "egui-backend")]
59    {
60        println!("Using egui GUI backend");
61        let backend = derive_wizard::EguiBackend::new()
62            .with_title("Derive Wizard Showcase")
63            .with_window_size([600.0, 700.0]);
64
65        let magic = ShowCase::wizard_builder()
66            .with_backend(backend)
67            .build()
68            .unwrap();
69        println!("=== Configuration Created ===");
70        println!("{magic:#?}");
71    }
72
73    #[cfg(not(feature = "egui-backend"))]
74    {
75        println!("Using default (requestty) backend");
76        println!("Run with --features egui-backend to use the GUI version");
77        println!();
78
79        let magic = ShowCase::wizard_builder().build().unwrap();
80        println!("=== Configuration Created ===");
81        println!("{magic:#?}");
82    }
83}