summaryrefslogtreecommitdiffstats
path: root/vendor/xflags/examples/longer.rs
blob: 199cca0429f1cc2eb409cf816883c468ae2b2737 (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
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
mod flags {
    #![allow(unused)]

    use std::path::PathBuf;

    xflags::xflags! {
        src "./examples/longer.rs"

        cmd rust-analyzer {
            /// Set verbosity level
            repeated -v, --verbose
            /// Log to the specified file instead of stderr.
            optional --log-file path: PathBuf

            default cmd run-server {
                /// Print version
                optional --version
            }

            /// Parse tree
            cmd parse {
                /// Suppress printing
                optional --no-dump
            }

            /// Benchmark specific analysis operation
            cmd analysis-bench {
                /// Directory with Cargo.toml
                optional path: PathBuf
                /// Compute syntax highlighting for this file
                required --highlight path: PathBuf
                /// Compute highlighting for this line
                optional --line num: u32
            }
        }
    }

    // generated start
    // The following code is generated by `xflags` macro.
    // Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
    #[derive(Debug)]
    pub struct RustAnalyzer {
        pub verbose: u32,
        pub log_file: Option<PathBuf>,
        pub subcommand: RustAnalyzerCmd,
    }

    #[derive(Debug)]
    pub enum RustAnalyzerCmd {
        RunServer(RunServer),
        Parse(Parse),
        AnalysisBench(AnalysisBench),
    }

    #[derive(Debug)]
    pub struct RunServer {
        pub version: bool,
    }

    #[derive(Debug)]
    pub struct Parse {
        pub no_dump: bool,
    }

    #[derive(Debug)]
    pub struct AnalysisBench {
        pub path: Option<PathBuf>,

        pub highlight: PathBuf,
        pub line: Option<u32>,
    }

    impl RustAnalyzer {
        #[allow(dead_code)]
        pub fn from_env() -> xflags::Result<Self> {
            Self::from_env_()
        }

        #[allow(dead_code)]
        pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
            Self::from_vec_(args)
        }
    }
    // generated end
}

fn main() {
    match flags::RustAnalyzer::from_env() {
        Ok(flags) => eprintln!("{:#?}", flags),
        Err(err) => eprintln!("{}", err),
    }
}