2
2
// warn on lints, that are included in `rust-lang/rust`s bootstrap
3
3
#![warn(rust_2018_idioms, unused_lifetimes)]
4
4
5
- use clap::{Arg, ArgAction, ArgMatches, Command, PossibleValue };
5
+ use clap::{Arg, ArgAction, ArgMatches, Command};
6
6
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
7
7
use indoc::indoc;
8
8
@@ -110,24 +110,37 @@ fn get_clap_config() -> ArgMatches {
110
110
Command::new("bless").about("bless the test output changes").arg(
111
111
Arg::new("ignore-timestamp")
112
112
.long("ignore-timestamp")
113
+ .action(ArgAction::SetTrue)
113
114
.help("Include files updated before clippy was built"),
114
115
),
115
116
Command::new("dogfood").about("Runs the dogfood test").args([
116
- Arg::new("fix").long("fix").help("Apply the suggestions when possible"),
117
+ Arg::new("fix")
118
+ .long("fix")
119
+ .action(ArgAction::SetTrue)
120
+ .help("Apply the suggestions when possible"),
117
121
Arg::new("allow-dirty")
118
122
.long("allow-dirty")
123
+ .action(ArgAction::SetTrue)
119
124
.help("Fix code even if the working directory has changes")
120
125
.requires("fix"),
121
126
Arg::new("allow-staged")
122
127
.long("allow-staged")
128
+ .action(ArgAction::SetTrue)
123
129
.help("Fix code even if the working directory has staged changes")
124
130
.requires("fix"),
125
131
]),
126
132
Command::new("fmt")
127
133
.about("Run rustfmt on all projects and tests")
128
134
.args([
129
- Arg::new("check").long("check").help("Use the rustfmt --check option"),
130
- Arg::new("verbose").short('v').long("verbose").help("Echo commands run"),
135
+ Arg::new("check")
136
+ .long("check")
137
+ .action(ArgAction::SetTrue)
138
+ .help("Use the rustfmt --check option"),
139
+ Arg::new("verbose")
140
+ .short('v')
141
+ .long("verbose")
142
+ .action(ArgAction::SetTrue)
143
+ .help("Echo commands run"),
131
144
]),
132
145
Command::new("update_lints")
133
146
.about("Updates lint registration and information from the source code")
@@ -140,13 +153,17 @@ fn get_clap_config() -> ArgMatches {
140
153
* all lints are registered in the lint store",
141
154
)
142
155
.args([
143
- Arg::new("print-only").long("print-only").help(
144
- "Print a table of lints to STDOUT. \
145
- This does not include deprecated and internal lints. \
146
- (Does not modify any files)",
147
- ),
156
+ Arg::new("print-only")
157
+ .long("print-only")
158
+ .action(ArgAction::SetTrue)
159
+ .help(
160
+ "Print a table of lints to STDOUT. \
161
+ This does not include deprecated and internal lints. \
162
+ (Does not modify any files)",
163
+ ),
148
164
Arg::new("check")
149
165
.long("check")
166
+ .action(ArgAction::SetTrue)
150
167
.help("Checks that `cargo dev update_lints` has been run. Used on CI."),
151
168
]),
152
169
Command::new("new_lint")
@@ -156,41 +173,37 @@ fn get_clap_config() -> ArgMatches {
156
173
.short('p')
157
174
.long("pass")
158
175
.help("Specify whether the lint runs during the early or late pass")
159
- .takes_value(true)
160
- .value_parser([PossibleValue::new("early"), PossibleValue::new("late")])
176
+ .value_parser(["early", "late"])
161
177
.conflicts_with("type")
162
178
.required_unless_present("type"),
163
179
Arg::new("name")
164
180
.short('n')
165
181
.long("name")
166
182
.help("Name of the new lint in snake case, ex: fn_too_long")
167
- .takes_value(true)
168
183
.required(true),
169
184
Arg::new("category")
170
185
.short('c')
171
186
.long("category")
172
187
.help("What category the lint belongs to")
173
188
.default_value("nursery")
174
189
.value_parser([
175
- PossibleValue::new("style"),
176
- PossibleValue::new("correctness"),
177
- PossibleValue::new("suspicious"),
178
- PossibleValue::new("complexity"),
179
- PossibleValue::new("perf"),
180
- PossibleValue::new("pedantic"),
181
- PossibleValue::new("restriction"),
182
- PossibleValue::new("cargo"),
183
- PossibleValue::new("nursery"),
184
- PossibleValue::new("internal"),
185
- PossibleValue::new("internal_warn"),
186
- ])
187
- .takes_value(true),
188
- Arg::new("type")
189
- .long("type")
190
- .help("What directory the lint belongs in")
191
- .takes_value(true)
192
- .required(false),
193
- Arg::new("msrv").long("msrv").help("Add MSRV config code to the lint"),
190
+ "style",
191
+ "correctness",
192
+ "suspicious",
193
+ "complexity",
194
+ "perf",
195
+ "pedantic",
196
+ "restriction",
197
+ "cargo",
198
+ "nursery",
199
+ "internal",
200
+ "internal_warn",
201
+ ]),
202
+ Arg::new("type").long("type").help("What directory the lint belongs in"),
203
+ Arg::new("msrv")
204
+ .long("msrv")
205
+ .action(ArgAction::SetTrue)
206
+ .help("Add MSRV config code to the lint"),
194
207
]),
195
208
Command::new("setup")
196
209
.about("Support for setting up your personal development environment")
@@ -201,13 +214,12 @@ fn get_clap_config() -> ArgMatches {
201
214
.args([
202
215
Arg::new("remove")
203
216
.long("remove")
204
- .help("Remove the dependencies added with 'cargo dev setup intellij'" )
205
- .required(false ),
217
+ .action(ArgAction::SetTrue )
218
+ .help("Remove the dependencies added with 'cargo dev setup intellij'" ),
206
219
Arg::new("rustc-repo-path")
207
220
.long("repo-path")
208
221
.short('r')
209
222
.help("The path to a rustc repo that will be used for setting the dependencies")
210
- .takes_value(true)
211
223
.value_name("path")
212
224
.conflicts_with("remove")
213
225
.required(true),
@@ -217,26 +229,26 @@ fn get_clap_config() -> ArgMatches {
217
229
.args([
218
230
Arg::new("remove")
219
231
.long("remove")
220
- .help("Remove the pre-commit hook added with 'cargo dev setup git-hook'" )
221
- .required(false ),
232
+ .action(ArgAction::SetTrue )
233
+ .help("Remove the pre-commit hook added with 'cargo dev setup git-hook'" ),
222
234
Arg::new("force-override")
223
235
.long("force-override")
224
236
.short('f')
225
- .help("Forces the override of an existing git pre-commit hook" )
226
- .required(false ),
237
+ .action(ArgAction::SetTrue )
238
+ .help("Forces the override of an existing git pre-commit hook" ),
227
239
]),
228
240
Command::new("vscode-tasks")
229
241
.about("Add several tasks to vscode for formatting, validation and testing")
230
242
.args([
231
243
Arg::new("remove")
232
244
.long("remove")
233
- .help("Remove the tasks added with 'cargo dev setup vscode-tasks'" )
234
- .required(false ),
245
+ .action(ArgAction::SetTrue )
246
+ .help("Remove the tasks added with 'cargo dev setup vscode-tasks'" ),
235
247
Arg::new("force-override")
236
248
.long("force-override")
237
249
.short('f')
238
- .help("Forces the override of existing vscode tasks" )
239
- .required(false ),
250
+ .action(ArgAction::SetTrue )
251
+ .help("Forces the override of existing vscode tasks" ),
240
252
]),
241
253
]),
242
254
Command::new("remove")
@@ -295,6 +307,7 @@ fn get_clap_config() -> ArgMatches {
295
307
.help("The new name of the lint"),
296
308
Arg::new("uplift")
297
309
.long("uplift")
310
+ .action(ArgAction::SetTrue)
298
311
.help("This lint will be uplifted into rustc"),
299
312
]),
300
313
Command::new("deprecate").about("Deprecates the given lint").args([
@@ -305,8 +318,6 @@ fn get_clap_config() -> ArgMatches {
305
318
Arg::new("reason")
306
319
.long("reason")
307
320
.short('r')
308
- .required(false)
309
- .takes_value(true)
310
321
.help("The reason for deprecation"),
311
322
]),
312
323
])
0 commit comments