1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#[derive(Debug, Clone)]
pub struct Command {
pub cmd_level: u8,
pub name: String,
pub desc: String,
pub executor: String,
pub source: String,
pub subcommands: Vec<Command>,
pub required_args: Vec<RequiredArg>,
pub option_flags: Vec<OptionFlag>,
}
impl Command {
pub fn new(cmd_level: u8) -> Self {
Self {
cmd_level,
name: "".to_string(),
desc: "".to_string(),
executor: "".to_string(),
source: "".to_string(),
subcommands: vec![],
required_args: vec![],
option_flags: vec![OptionFlag {
name: "verbose".to_string(),
desc: "Sets the level of verbosity".to_string(),
short: "v".to_string(),
long: "verbose".to_string(),
multiple: false,
takes_value: false,
val: "".to_string(),
}],
}
}
}
#[derive(Debug, Clone)]
pub struct RequiredArg {
pub name: String,
pub val: String,
}
impl RequiredArg {
pub fn new(name: String) -> Self {
Self {
name,
val: "".to_string(),
}
}
}
#[derive(Debug, Clone)]
pub struct OptionFlag {
pub name: String,
pub desc: String,
pub short: String,
pub long: String,
pub multiple: bool,
pub takes_value: bool,
pub val: String,
}
impl OptionFlag {
pub fn new() -> Self {
Self {
name: "".to_string(),
desc: "".to_string(),
short: "".to_string(),
long: "".to_string(),
multiple: false,
takes_value: false,
val: "".to_string(),
}
}
}