@@ -7,6 +7,7 @@ use cargo::ops::CleanContext;
77use cargo:: ops:: { self , CleanOptions } ;
88use cargo:: util:: print_available_packages;
99use clap_complete:: ArgValueCandidates ;
10+ use indexmap:: IndexSet ;
1011use std:: time:: Duration ;
1112
1213pub fn cli ( ) -> Command {
@@ -18,6 +19,10 @@ pub fn cli() -> Command {
1819 "Package to clean artifacts for" ,
1920 ArgValueCandidates :: new ( get_pkg_name_candidates) ,
2021 )
22+ . arg (
23+ flag ( "workspace" , "Clean artifacts of the workspace members" )
24+ . help_heading ( heading:: PACKAGE_SELECTION ) ,
25+ )
2126 . arg_release ( "Whether or not to clean release artifacts" )
2227 . arg_profile ( "Clean artifacts of the specified profile" )
2328 . arg_target_triple ( "Target triple to clean output for" )
@@ -146,10 +151,14 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
146151 if args. is_present_with_zero_values ( "package" ) {
147152 print_available_packages ( & ws) ?;
148153 }
154+ let mut spec = IndexSet :: from_iter ( values ( args, "package" ) ) ;
149155
156+ if args. flag ( "workspace" ) {
157+ spec. extend ( ws. members ( ) . map ( |package| package. name ( ) . to_string ( ) ) )
158+ } ;
150159 let opts = CleanOptions {
151160 gctx,
152- spec : values ( args , "package" ) ,
161+ spec,
153162 targets : args. targets ( ) ?,
154163 requested_profile : args. get_profile_name ( "dev" , ProfileChecking :: Custom ) ?,
155164 profile_specified : args. contains_id ( "profile" ) || args. flag ( "release" ) ,
0 commit comments