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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
///
/// Declare your arguments using this macro.
///
/// Possible patterns:
/// ```
/// use badargs::arg;
///
/// arg!(LongOrShort: "long-or-short", 's' -> bool);
/// arg!(OnlyLong: "only-long" -> bool);
/// arg!(pub OtherModule: "other-module" -> bool);
/// ```
///
///
/// ```
/// use badargs::arg;
///
/// arg!(Force: "force", 'f' -> bool);
/// ```
/// is a shorthand for
/// ```
/// use badargs::{arg, CliArg};
///
/// struct Force;
///
/// impl CliArg for Force {
/// type Content = bool;
///
/// fn long() -> &'static str {
/// "force"
/// }
///
/// fn short() -> Option<char> {
/// Some('f')
/// }
/// }
/// ```
}
};
}
///
/// A shorthand for calling the [`badargs`](crate::badargs()) main function
///
/// This macro lets you specify your arguments in a flat list, and then converts them into
/// nested tuples for you, since that's what's internally used.
/// ```
/// use badargs::arg;
/// arg!(Force: "force", 'f' -> bool);
/// arg!(OutFile: "outfile", 't' -> bool);
/// arg!(SetUpstream: "set-upstream", 'x' -> bool);
///
/// fn main() {
/// let args = badargs::badargs!(Force, OutFile, SetUpstream);
/// }
/// ```
/// will be expanded into
/// ```
/// use badargs::arg;
/// arg!(Force: "force", 'f' -> bool);
/// arg!(OutFile: "outfile", 't' -> bool);
/// arg!(SetUpstream: "set-upstream", 'x' -> bool);
///
/// fn main() {
/// let args = badargs::badargs::<(Force, (OutFile, SetUpstream))>();
/// }
/// ```
/// This only provides a minor benefit for programs with a small amount of args, but is
/// very useful for larger arg amounts.