22// warn on lints, that are included in `rust-lang/rust`s bootstrap
33#![ warn( rust_2018_idioms, unused_lifetimes) ]
44
5- use clap:: { Arg , ArgAction , ArgMatches , Command , PossibleValue } ;
5+ use clap:: { Arg , ArgAction , ArgMatches , Command } ;
66use clippy_dev:: { bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints} ;
77use indoc:: indoc;
88
@@ -110,24 +110,37 @@ fn get_clap_config() -> ArgMatches {
110110 Command :: new ( "bless" ) . about ( "bless the test output changes" ) . arg (
111111 Arg :: new ( "ignore-timestamp" )
112112 . long ( "ignore-timestamp" )
113+ . action ( ArgAction :: SetTrue )
113114 . help ( "Include files updated before clippy was built" ) ,
114115 ) ,
115116 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" ) ,
117121 Arg :: new ( "allow-dirty" )
118122 . long ( "allow-dirty" )
123+ . action ( ArgAction :: SetTrue )
119124 . help ( "Fix code even if the working directory has changes" )
120125 . requires ( "fix" ) ,
121126 Arg :: new ( "allow-staged" )
122127 . long ( "allow-staged" )
128+ . action ( ArgAction :: SetTrue )
123129 . help ( "Fix code even if the working directory has staged changes" )
124130 . requires ( "fix" ) ,
125131 ] ) ,
126132 Command :: new ( "fmt" )
127133 . about ( "Run rustfmt on all projects and tests" )
128134 . 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" ) ,
131144 ] ) ,
132145 Command :: new ( "update_lints" )
133146 . about ( "Updates lint registration and information from the source code" )
@@ -140,13 +153,17 @@ fn get_clap_config() -> ArgMatches {
140153 * all lints are registered in the lint store",
141154 )
142155 . 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+ ) ,
148164 Arg :: new ( "check" )
149165 . long ( "check" )
166+ . action ( ArgAction :: SetTrue )
150167 . help ( "Checks that `cargo dev update_lints` has been run. Used on CI." ) ,
151168 ] ) ,
152169 Command :: new ( "new_lint" )
@@ -156,41 +173,37 @@ fn get_clap_config() -> ArgMatches {
156173 . short ( 'p' )
157174 . long ( "pass" )
158175 . 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" ] )
161177 . conflicts_with ( "type" )
162178 . required_unless_present ( "type" ) ,
163179 Arg :: new ( "name" )
164180 . short ( 'n' )
165181 . long ( "name" )
166182 . help ( "Name of the new lint in snake case, ex: fn_too_long" )
167- . takes_value ( true )
168183 . required ( true ) ,
169184 Arg :: new ( "category" )
170185 . short ( 'c' )
171186 . long ( "category" )
172187 . help ( "What category the lint belongs to" )
173188 . default_value ( "nursery" )
174189 . 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" ) ,
194207 ] ) ,
195208 Command :: new ( "setup" )
196209 . about ( "Support for setting up your personal development environment" )
@@ -201,13 +214,12 @@ fn get_clap_config() -> ArgMatches {
201214 . args ( [
202215 Arg :: new ( "remove" )
203216 . 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'" ) ,
206219 Arg :: new ( "rustc-repo-path" )
207220 . long ( "repo-path" )
208221 . short ( 'r' )
209222 . help ( "The path to a rustc repo that will be used for setting the dependencies" )
210- . takes_value ( true )
211223 . value_name ( "path" )
212224 . conflicts_with ( "remove" )
213225 . required ( true ) ,
@@ -217,26 +229,26 @@ fn get_clap_config() -> ArgMatches {
217229 . args ( [
218230 Arg :: new ( "remove" )
219231 . 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'" ) ,
222234 Arg :: new ( "force-override" )
223235 . long ( "force-override" )
224236 . 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" ) ,
227239 ] ) ,
228240 Command :: new ( "vscode-tasks" )
229241 . about ( "Add several tasks to vscode for formatting, validation and testing" )
230242 . args ( [
231243 Arg :: new ( "remove" )
232244 . 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'" ) ,
235247 Arg :: new ( "force-override" )
236248 . long ( "force-override" )
237249 . 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" ) ,
240252 ] ) ,
241253 ] ) ,
242254 Command :: new ( "remove" )
@@ -295,6 +307,7 @@ fn get_clap_config() -> ArgMatches {
295307 . help ( "The new name of the lint" ) ,
296308 Arg :: new ( "uplift" )
297309 . long ( "uplift" )
310+ . action ( ArgAction :: SetTrue )
298311 . help ( "This lint will be uplifted into rustc" ) ,
299312 ] ) ,
300313 Command :: new ( "deprecate" ) . about ( "Deprecates the given lint" ) . args ( [
@@ -305,8 +318,6 @@ fn get_clap_config() -> ArgMatches {
305318 Arg :: new ( "reason" )
306319 . long ( "reason" )
307320 . short ( 'r' )
308- . required ( false )
309- . takes_value ( true )
310321 . help ( "The reason for deprecation" ) ,
311322 ] ) ,
312323 ] )
0 commit comments