string_and_numeric/
string_and_numeric.rs

1///
2/// String and numeric terminal-menu items explained.
3///
4
5fn main() {
6    use terminal_menu::{menu, label, button, string, numeric, run, mut_menu};
7    let menu = menu(vec![
8        label("strings and numerics"),
9
10        // string:
11        //  a string of characters
12        //  the last arguments specifies if empty strings are allowed
13
14        // empty strings allowed:
15        string("ste", "default", true),
16
17        // empty strings not allowed:
18        string("stn", "default", false),
19
20        // numeric:
21        //  a floating point number
22        numeric("num",
23            // default
24            4.5,
25
26            // step
27            Some(1.5),
28
29            // minimum
30            None,
31
32            // maximum
33            Some(150.0)
34        ),
35
36        button("exit")
37    ]);
38    run(&menu);
39    {
40        let mm = mut_menu(&menu);
41        println!("{}", mm.selection_value("ste"));
42        println!("{}", mm.selection_value("stn"));
43        println!("{}", mm.numeric_value("num"));
44    }
45}