aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/flags.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-03-01 18:12:44 +0000
committerAleksey Kladov <[email protected]>2021-03-01 19:12:43 +0000
commit4ce20b80c5ca5e0523980aa8dd95b1cc76d78d59 (patch)
treecdd4c3c2b0406548415315ccafb6312860ffa402 /xtask/src/flags.rs
parent9860a396035f61a5cc9265c1104a640547bded51 (diff)
Use cli parser with auto-generated help
Diffstat (limited to 'xtask/src/flags.rs')
-rw-r--r--xtask/src/flags.rs139
1 files changed, 139 insertions, 0 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
new file mode 100644
index 000000000..ce72879a1
--- /dev/null
+++ b/xtask/src/flags.rs
@@ -0,0 +1,139 @@
1#![allow(unreachable_pub)]
2
3xflags::args_parser! {
4 /// Run custom build command.
5 cmd xtask {
6 default cmd help {
7 /// Print help information.
8 optional -h, --help
9 }
10
11 /// Install rust-analyzer server or editor plugin.
12 cmd install {
13 /// Install only VS Code plugin.
14 optional --client
15 /// One of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'.
16 optional --code-bin name: String
17
18 /// Install only the language server.
19 optional --server
20 /// Use mimalloc allocator for server
21 optional --mimalloc
22 /// Use jemalloc allocator for server
23 optional --jemalloc
24 }
25
26 cmd codegen {
27 optional --features
28 }
29
30 cmd lint {}
31 cmd fuzz-tests {}
32 cmd pre-cache {}
33
34 cmd release {
35 optional --dry-run
36 }
37 cmd promote {
38 optional --dry-run
39 }
40 cmd dist {
41 optional --nightly
42 optional --client version: String
43 }
44 cmd metrics {
45 optional --dry-run
46 }
47 /// Builds a benchmark version of rust-analyzer and puts it into `./target`.
48 cmd bb
49 required suffix : String
50 {}
51 }
52}
53
54// generated start
55// The following code is generated by `xflags` macro.
56// Run `env XFLAGS_DUMP= cargo build` to regenerate.
57#[derive(Debug)]
58pub struct Xtask {
59 pub subcommand: XtaskCmd,
60}
61
62#[derive(Debug)]
63pub enum XtaskCmd {
64 Help(Help),
65 Install(Install),
66 Codegen(Codegen),
67 Lint(Lint),
68 FuzzTests(FuzzTests),
69 PreCache(PreCache),
70 Release(Release),
71 Promote(Promote),
72 Dist(Dist),
73 Metrics(Metrics),
74 Bb(Bb),
75}
76
77#[derive(Debug)]
78pub struct Help {
79 pub help: bool,
80}
81
82#[derive(Debug)]
83pub struct Install {
84 pub client: bool,
85 pub code_bin: Option<String>,
86 pub server: bool,
87 pub mimalloc: bool,
88 pub jemalloc: bool,
89}
90
91#[derive(Debug)]
92pub struct Codegen {
93 pub features: bool,
94}
95
96#[derive(Debug)]
97pub struct Lint {}
98
99#[derive(Debug)]
100pub struct FuzzTests {}
101
102#[derive(Debug)]
103pub struct PreCache {}
104
105#[derive(Debug)]
106pub struct Release {
107 pub dry_run: bool,
108}
109
110#[derive(Debug)]
111pub struct Promote {
112 pub dry_run: bool,
113}
114
115#[derive(Debug)]
116pub struct Dist {
117 pub nightly: bool,
118 pub client: Option<String>,
119}
120
121#[derive(Debug)]
122pub struct Metrics {
123 pub dry_run: bool,
124}
125
126#[derive(Debug)]
127pub struct Bb {
128 pub suffix: String,
129}
130
131impl Xtask {
132 pub const HELP: &'static str = Self::_HELP;
133
134 pub fn from_env() -> xflags::Result<Self> {
135 let mut p = xflags::rt::Parser::new_from_env();
136 Self::_parse(&mut p)
137 }
138}
139// generated end