1use clap::Parser;
2
3#[derive(Debug, Parser)]
4pub struct CheckFlags {
5 #[arg(short, long, value_name = "SPEC", help_heading = "Package Selection")]
7 package: Vec<String>,
8
9 #[arg(long, help_heading = "Package Selection")]
11 workspace: bool,
12
13 #[arg(long, value_name = "SPEC", help_heading = "Package Selection")]
15 exclude: Vec<String>,
16
17 #[arg(long, help_heading = "Package Selection")]
19 all: bool,
20
21 #[arg(long, help_heading = "Target Selection")]
23 lib: bool,
24
25 #[arg(long, help_heading = "Target Selection")]
27 bins: bool,
28
29 #[arg(long, value_name = "NAME", help_heading = "Target Selection")]
31 bin: Option<String>,
32
33 #[arg(long, help_heading = "Target Selection")]
35 examples: bool,
36
37 #[arg(long, value_name = "NAME", help_heading = "Target Selection")]
39 example: Option<String>,
40
41 #[arg(long, help_heading = "Target Selection")]
43 tests: bool,
44
45 #[arg(long, value_name = "NAME", help_heading = "Target Selection")]
47 test: Option<String>,
48
49 #[arg(long, help_heading = "Target Selection")]
51 benches: bool,
52
53 #[arg(long, value_name = "NAME", help_heading = "Target Selection")]
55 bench: Option<String>,
56
57 #[arg(long, help_heading = "Target Selection")]
59 all_targets: bool,
60
61 #[arg(
63 short = 'F',
64 long,
65 value_name = "FEATURES",
66 help_heading = "Feature Selection"
67 )]
68 features: Vec<String>,
69
70 #[arg(long, help_heading = "Feature Selection")]
72 all_features: bool,
73
74 #[arg(long, help_heading = "Feature Selection")]
76 no_default_features: bool,
77
78 #[arg(short = 'Z', value_name = "FLAG")]
80 unstable_flags: Vec<String>,
81
82 #[arg(long, value_name = "N", help_heading = "Compilation Options")]
84 jobs: Option<usize>,
85
86 #[arg(long, help_heading = "Compilation Options")]
88 release: bool,
89
90 #[arg(
92 long,
93 value_name = "PROFILE-NAME",
94 help_heading = "Compilation Options"
95 )]
96 profile: Option<String>,
97
98 #[arg(long, value_name = "TRIPLE", help_heading = "Compilation Options")]
100 target: Vec<String>,
101
102 #[arg(long, value_name = "DIRECTORY", help_heading = "Compilation Options")]
104 target_dir: Option<String>,
105
106 #[arg(long, value_name = "PATH", help_heading = "Manifest Options")]
108 manifest_path: Option<String>,
109
110 #[arg(long, value_name = "PATH", help_heading = "Manifest Options")]
112 lockfile_path: Option<String>,
113
114 #[arg(long, help_heading = "Manifest Options")]
116 ignore_rust_version: bool,
117
118 #[arg(long, help_heading = "Manifest Options")]
120 locked: bool,
121
122 #[arg(long, help_heading = "Manifest Options")]
124 offline: bool,
125
126 #[arg(long, help_heading = "Manifest Options")]
128 frozen: bool,
129}
130
131impl CheckFlags {
132 pub fn to_flags(&self) -> Vec<String> {
133 let mut out = Vec::new();
134
135 for spec in self.package.clone() {
136 out.push("--package".to_owned());
137 out.push(spec);
138 }
139 if self.workspace {
140 out.push("--workspace".to_owned());
141 }
142 for spec in self.exclude.clone() {
143 out.push("--exclude".to_owned());
144 out.push(spec);
145 }
146 if self.all {
147 out.push("--all".to_owned());
148 }
149
150 if self.lib {
151 out.push("--lib".to_owned());
152 }
153
154 if self.bins {
155 out.push("--bins".to_owned());
156 }
157 if let Some(b) = self.bin.clone() {
158 out.push("--bin".to_owned());
159 out.push(b);
160 }
161
162 if self.examples {
163 out.push("--examples".to_owned());
164 }
165 if let Some(b) = self.example.clone() {
166 out.push("--example".to_owned());
167 out.push(b);
168 }
169
170 if self.tests {
171 out.push("--tests".to_owned());
172 }
173 if let Some(b) = self.test.clone() {
174 out.push("--test".to_owned());
175 out.push(b);
176 }
177
178 if self.benches {
179 out.push("--benches".to_owned());
180 }
181 if let Some(b) = self.bench.clone() {
182 out.push("--bench".to_owned());
183 out.push(b);
184 }
185
186 if self.all_targets {
187 out.push("--all-targets".to_owned());
188 }
189
190 for i in self.features.clone() {
191 out.push("--features".to_owned());
192 out.push(i);
193 }
194 if self.all_features {
195 out.push("--all-features".to_owned());
196 }
197 if self.no_default_features {
198 out.push("--no-default-features".to_owned());
199 }
200
201 for i in self.unstable_flags.clone() {
202 out.push("-Z".to_owned());
203 out.push(i);
204 }
205
206 if let Some(b) = self.jobs {
207 out.push("--jobs".to_owned());
208 out.push(b.to_string());
209 }
210 if self.release {
211 out.push("--release".to_owned());
212 }
213 if let Some(b) = self.profile.clone() {
214 out.push("--profile".to_owned());
215 out.push(b);
216 }
217
218 for spec in self.target.clone() {
219 out.push("--target".to_owned());
220 out.push(spec);
221 }
222 if let Some(b) = self.target_dir.clone() {
223 out.push("--target-dir".to_owned());
224 out.push(b);
225 }
226
227 if let Some(b) = self.manifest_path.clone() {
228 out.push("--manifest-path".to_owned());
229 out.push(b);
230 }
231 if let Some(b) = self.lockfile_path.clone() {
232 out.push("--lockfile-path".to_owned());
233 out.push(b);
234 }
235 if self.ignore_rust_version {
236 out.push("--ignore-rust-version".to_owned());
237 }
238 if self.locked {
239 out.push("--locked".to_owned());
240 }
241 if self.offline {
242 out.push("--offline".to_owned());
243 }
244 if self.frozen {
245 out.push("--frozen".to_owned());
246 }
247 out
248 }
249}