1 use args::{Arg, ArgFlags, ArgSettings};
2 
3 #[derive(Debug, Clone, Default)]
4 pub struct Base<'a, 'b>
5 where
6     'a: 'b,
7 {
8     pub name: &'a str,
9     pub help: Option<&'b str>,
10     pub long_help: Option<&'b str>,
11     pub blacklist: Option<Vec<&'a str>>,
12     pub settings: ArgFlags,
13     pub r_unless: Option<Vec<&'a str>>,
14     pub overrides: Option<Vec<&'a str>>,
15     pub groups: Option<Vec<&'a str>>,
16     pub requires: Option<Vec<(Option<&'b str>, &'a str)>>,
17 }
18 
19 impl<'n, 'e> Base<'n, 'e> {
new(name: &'n str) -> Self20     pub fn new(name: &'n str) -> Self {
21         Base {
22             name: name,
23             ..Default::default()
24         }
25     }
26 
set(&mut self, s: ArgSettings)27     pub fn set(&mut self, s: ArgSettings) {
28         self.settings.set(s);
29     }
unset(&mut self, s: ArgSettings)30     pub fn unset(&mut self, s: ArgSettings) {
31         self.settings.unset(s);
32     }
is_set(&self, s: ArgSettings) -> bool33     pub fn is_set(&self, s: ArgSettings) -> bool {
34         self.settings.is_set(s)
35     }
36 }
37 
38 impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Base<'n, 'e> {
from(a: &'z Arg<'n, 'e>) -> Self39     fn from(a: &'z Arg<'n, 'e>) -> Self {
40         a.b.clone()
41     }
42 }
43 
44 impl<'n, 'e> PartialEq for Base<'n, 'e> {
eq(&self, other: &Base<'n, 'e>) -> bool45     fn eq(&self, other: &Base<'n, 'e>) -> bool {
46         self.name == other.name
47     }
48 }
49