summaryrefslogtreecommitdiffstats
path: root/vendor/xflags-macros/src/ast.rs
blob: 5ccebd95194d67d370323b6a6c9b6ee79e882002 (plain)
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
#[derive(Debug)]
pub(crate) struct XFlags {
    pub(crate) src: Option<String>,
    pub(crate) cmd: Cmd,
}

#[derive(Debug)]
pub(crate) struct Cmd {
    pub(crate) name: String,
    pub(crate) doc: Option<String>,
    pub(crate) args: Vec<Arg>,
    pub(crate) flags: Vec<Flag>,
    pub(crate) subcommands: Vec<Cmd>,
    pub(crate) default: bool,
}

#[derive(Debug)]
pub(crate) struct Arg {
    pub(crate) arity: Arity,
    pub(crate) doc: Option<String>,
    pub(crate) val: Val,
}

#[derive(Debug)]
pub(crate) struct Flag {
    pub(crate) arity: Arity,
    pub(crate) name: String,
    pub(crate) short: Option<String>,
    pub(crate) doc: Option<String>,
    pub(crate) val: Option<Val>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum Arity {
    Optional,
    Required,
    Repeated,
}

#[derive(Debug)]
pub(crate) struct Val {
    pub(crate) name: String,
    pub(crate) ty: Ty,
}

#[derive(Debug)]
pub(crate) enum Ty {
    PathBuf,
    OsString,
    FromStr(String),
}