This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use std::collections::HashMap;
1212use std:: process:: Command ;
1313use std:: { fmt, fs:: write, path:: PathBuf } ;
1414
15+ use clap:: ArgMatches ;
1516use serde:: { Deserialize , Serialize } ;
1617use serde_json:: Value ;
1718
@@ -200,7 +201,7 @@ fn parse_json_message(json_message: &str, krate: &Crate) -> ClippyWarning {
200201}
201202
202203// the main fn
203- pub fn run ( ) {
204+ pub fn run ( clap_config : & ArgMatches ) {
204205 let cargo_clippy_path: PathBuf = PathBuf :: from ( "target/debug/cargo-clippy" ) ;
205206
206207 println ! ( "Compiling clippy..." ) ;
@@ -217,12 +218,23 @@ pub fn run() {
217218 // download and extract the crates, then run clippy on them and collect clippys warnings
218219 // flatten into one big list of warnings
219220
220- let clippy_warnings: Vec < ClippyWarning > = read_crates ( )
221- . into_iter ( )
222- . map ( |krate| krate. download_and_extract ( ) )
223- . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path) )
224- . flatten ( )
225- . collect ( ) ;
221+ let clippy_warnings: Vec < ClippyWarning > = if let Some ( only_one_crate) = clap_config. value_of ( "only" ) {
222+ // only check a single
223+ read_crates ( )
224+ . into_iter ( )
225+ . map ( |krate| krate. download_and_extract ( ) )
226+ . filter ( |krate| krate. name == only_one_crate)
227+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path) )
228+ . flatten ( )
229+ . collect ( )
230+ } else {
231+ read_crates ( )
232+ . into_iter ( )
233+ . map ( |krate| krate. download_and_extract ( ) )
234+ . map ( |krate| krate. run_clippy_lints ( & cargo_clippy_path) )
235+ . flatten ( )
236+ . collect ( )
237+ } ;
226238
227239 // generate some stats:
228240
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ fn main() {
1010 ( "bless" , Some ( matches) ) => {
1111 bless:: bless ( matches. is_present ( "ignore-timestamp" ) ) ;
1212 } ,
13- ( "crater" , Some ( _ ) ) => {
14- crater:: run ( ) ;
13+ ( "crater" , Some ( matches ) ) => {
14+ crater:: run ( & matches ) ;
1515 } ,
1616 ( "fmt" , Some ( matches) ) => {
1717 fmt:: run ( matches. is_present ( "check" ) , matches. is_present ( "verbose" ) ) ;
@@ -59,7 +59,17 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
5959 . help ( "Include files updated before clippy was built" ) ,
6060 ) ,
6161 )
62- . subcommand ( SubCommand :: with_name ( "crater" ) . about ( "run clippy on a set of crates and check output" ) )
62+ . subcommand (
63+ SubCommand :: with_name ( "crater" )
64+ . about ( "run clippy on a set of crates and check output" )
65+ . arg (
66+ Arg :: with_name ( "only" )
67+ . takes_value ( true )
68+ . value_name ( "CRATE" )
69+ . long ( "only" )
70+ . help ( "only process a single crate of the list" ) ,
71+ ) ,
72+ )
6373 . subcommand (
6474 SubCommand :: with_name ( "fmt" )
6575 . about ( "Run rustfmt on all projects and tests" )
You can’t perform that action at this time.
0 commit comments