@@ -60,7 +60,9 @@ pub enum Subcommand {
60
60
paths : Vec < PathBuf > ,
61
61
test_args : Vec < String > ,
62
62
} ,
63
- Clean ,
63
+ Clean {
64
+ all : bool ,
65
+ } ,
64
66
Dist {
65
67
paths : Vec < PathBuf > ,
66
68
} ,
@@ -147,6 +149,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
147
149
opts. optmulti ( "" , "test-args" , "extra arguments" , "ARGS" ) ;
148
150
} ,
149
151
"bench" => { opts. optmulti ( "" , "test-args" , "extra arguments" , "ARGS" ) ; } ,
152
+ "clean" => { opts. optflag ( "" , "all" , "clean all build artifacts" ) ; } ,
150
153
_ => { } ,
151
154
} ;
152
155
@@ -250,17 +253,18 @@ Arguments:
250
253
}
251
254
} ) ;
252
255
253
- // All subcommands can have an optional "Available paths" section
256
+ // All subcommands except `clean` can have an optional "Available paths" section
254
257
if matches. opt_present ( "verbose" ) {
255
258
let config = Config :: parse ( & [ "build" . to_string ( ) ] ) ;
256
259
let mut build = Build :: new ( config) ;
257
260
metadata:: build ( & mut build) ;
258
261
259
262
let maybe_rules_help = Builder :: get_help ( & build, subcommand. as_str ( ) ) ;
260
263
extra_help. push_str ( maybe_rules_help. unwrap_or_default ( ) . as_str ( ) ) ;
261
- } else {
262
- extra_help. push_str ( format ! ( "Run `./x.py {} -h -v` to see a list of available paths." ,
263
- subcommand) . as_str ( ) ) ;
264
+ } else if subcommand. as_str ( ) != "clean" {
265
+ extra_help. push_str ( format ! (
266
+ "Run `./x.py {} -h -v` to see a list of available paths." ,
267
+ subcommand) . as_str ( ) ) ;
264
268
}
265
269
266
270
// User passed in -h/--help?
@@ -290,10 +294,13 @@ Arguments:
290
294
}
291
295
"clean" => {
292
296
if paths. len ( ) > 0 {
293
- println ! ( "\n clean takes no arguments \n " ) ;
297
+ println ! ( "\n clean does not take a path argument \n " ) ;
294
298
usage ( 1 , & opts, & subcommand_help, & extra_help) ;
295
299
}
296
- Subcommand :: Clean
300
+
301
+ Subcommand :: Clean {
302
+ all : matches. opt_present ( "all" ) ,
303
+ }
297
304
}
298
305
"dist" => {
299
306
Subcommand :: Dist {
0 commit comments