primitives/
primitives.rs

1use parse_argument::parse_argument;
2use std::process::exit;
3
4fn main() { 
5    let num = parse_argument::<u8>("num")
6        // use unwrap_or() to set a default value
7        .unwrap_or(Ok(2))
8        // use .map_err() to handle any errors (I like to close the program with these errors)
9        .map_err(|e| {
10            println!("Argument didn't parse: {e:?}");
11            exit(1);
12        })
13        .unwrap()
14    ;
15
16    println!("{num}");
17
18    exit(0);
19}