1
1
#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
2
2
3
- use clap:: { App , Arg , SubCommand } ;
3
+ use clap:: { App , Arg , ArgMatches , SubCommand } ;
4
4
use clippy_dev:: { bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints} ;
5
5
6
6
fn main ( ) {
7
- let matches = App :: new ( "Clippy developer tooling" )
7
+ let matches = get_clap_config ( ) ;
8
+
9
+ match matches. subcommand ( ) {
10
+ ( "bless" , Some ( _) ) => {
11
+ bless:: bless ( ) ;
12
+ } ,
13
+ ( "fmt" , Some ( matches) ) => {
14
+ fmt:: run ( matches. is_present ( "check" ) , matches. is_present ( "verbose" ) ) ;
15
+ } ,
16
+ ( "update_lints" , Some ( matches) ) => {
17
+ if matches. is_present ( "print-only" ) {
18
+ update_lints:: print_lints ( ) ;
19
+ } else if matches. is_present ( "check" ) {
20
+ update_lints:: run ( update_lints:: UpdateMode :: Check ) ;
21
+ } else {
22
+ update_lints:: run ( update_lints:: UpdateMode :: Change ) ;
23
+ }
24
+ } ,
25
+ ( "new_lint" , Some ( matches) ) => {
26
+ match new_lint:: create (
27
+ matches. value_of ( "pass" ) ,
28
+ matches. value_of ( "name" ) ,
29
+ matches. value_of ( "category" ) ,
30
+ ) {
31
+ Ok ( _) => update_lints:: run ( update_lints:: UpdateMode :: Change ) ,
32
+ Err ( e) => eprintln ! ( "Unable to create lint: {}" , e) ,
33
+ }
34
+ } ,
35
+ ( "limit_stderr_length" , _) => {
36
+ stderr_length_check:: check ( ) ;
37
+ } ,
38
+ ( "ra_setup" , Some ( matches) ) => ra_setup:: run ( matches. value_of ( "rustc-repo-path" ) ) ,
39
+ ( "serve" , Some ( matches) ) => {
40
+ let port = matches. value_of ( "port" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
41
+ let lint = matches. value_of ( "lint" ) ;
42
+ serve:: run ( port, lint) ;
43
+ } ,
44
+ _ => { } ,
45
+ }
46
+ }
47
+
48
+ fn get_clap_config < ' a > ( ) -> ArgMatches < ' a > {
49
+ App :: new ( "Clippy developer tooling" )
8
50
. subcommand ( SubCommand :: with_name ( "bless" ) . about ( "bless the test output changes" ) )
9
51
. subcommand (
10
52
SubCommand :: with_name ( "fmt" )
@@ -26,16 +68,16 @@ fn main() {
26
68
. about ( "Updates lint registration and information from the source code" )
27
69
. long_about (
28
70
"Makes sure that:\n \
29
- * the lint count in README.md is correct\n \
30
- * the changelog contains markdown link references at the bottom\n \
31
- * all lint groups include the correct lints\n \
32
- * lint modules in `clippy_lints/*` are visible in `src/lib .rs` via `pub mod`\n \
33
- * all lints are registered in the lint store",
71
+ * the lint count in README.md is correct\n \
72
+ * the changelog contains markdown link references at the bottom\n \
73
+ * all lint groups include the correct lints\n \
74
+ * lint modules in `clippy_lints/*` are visible in `src/lifb .rs` via `pub mod`\n \
75
+ * all lints are registered in the lint store",
34
76
)
35
77
. arg ( Arg :: with_name ( "print-only" ) . long ( "print-only" ) . help (
36
78
"Print a table of lints to STDOUT. \
37
- This does not include deprecated and internal lints. \
38
- (Does not modify any files)",
79
+ This does not include deprecated and internal lints. \
80
+ (Does not modify any files)",
39
81
) )
40
82
. arg (
41
83
Arg :: with_name ( "check" )
@@ -89,7 +131,7 @@ fn main() {
89
131
. about ( "Ensures that stderr files do not grow longer than a certain amount of lines." ) ,
90
132
)
91
133
. subcommand (
92
- SubCommand :: with_name ( "ra-setup " )
134
+ SubCommand :: with_name ( "ra_setup " )
93
135
. about ( "Alter dependencies so rust-analyzer can find rustc internals" )
94
136
. arg (
95
137
Arg :: with_name ( "rustc-repo-path" )
@@ -114,43 +156,5 @@ fn main() {
114
156
)
115
157
. arg ( Arg :: with_name ( "lint" ) . help ( "Which lint's page to load initially (optional)" ) ) ,
116
158
)
117
- . get_matches ( ) ;
118
-
119
- match matches. subcommand ( ) {
120
- ( "bless" , Some ( _) ) => {
121
- bless:: bless ( ) ;
122
- } ,
123
- ( "fmt" , Some ( matches) ) => {
124
- fmt:: run ( matches. is_present ( "check" ) , matches. is_present ( "verbose" ) ) ;
125
- } ,
126
- ( "update_lints" , Some ( matches) ) => {
127
- if matches. is_present ( "print-only" ) {
128
- update_lints:: print_lints ( ) ;
129
- } else if matches. is_present ( "check" ) {
130
- update_lints:: run ( update_lints:: UpdateMode :: Check ) ;
131
- } else {
132
- update_lints:: run ( update_lints:: UpdateMode :: Change ) ;
133
- }
134
- } ,
135
- ( "new_lint" , Some ( matches) ) => {
136
- match new_lint:: create (
137
- matches. value_of ( "pass" ) ,
138
- matches. value_of ( "name" ) ,
139
- matches. value_of ( "category" ) ,
140
- ) {
141
- Ok ( _) => update_lints:: run ( update_lints:: UpdateMode :: Change ) ,
142
- Err ( e) => eprintln ! ( "Unable to create lint: {}" , e) ,
143
- }
144
- } ,
145
- ( "limit_stderr_length" , _) => {
146
- stderr_length_check:: check ( ) ;
147
- } ,
148
- ( "ra-setup" , Some ( matches) ) => ra_setup:: run ( matches. value_of ( "rustc-repo-path" ) ) ,
149
- ( "serve" , Some ( matches) ) => {
150
- let port = matches. value_of ( "port" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
151
- let lint = matches. value_of ( "lint" ) ;
152
- serve:: run ( port, lint) ;
153
- } ,
154
- _ => { } ,
155
- }
159
+ . get_matches ( )
156
160
}
0 commit comments