@@ -352,26 +352,40 @@ def add_parser(subparsers, *args, **kwargs):
352352 "--compact" , action = "store_true" , default = False ,
353353 help = "Produce a compact list suitable for scripting" )
354354
355- parser_bootstraps = add_parser (subparsers ,
356- 'bootstraps' , help = 'List the available bootstraps' ,
355+ parser_bootstraps = add_parser (
356+ subparsers , 'bootstraps' ,
357+ help = 'List the available bootstraps' ,
357358 parents = [generic_parser ])
358- parser_clean_all = add_parser (subparsers ,
359- 'clean_all' , aliases = ['clean-all' ],
359+ parser_clean_all = add_parser (
360+ subparsers , 'clean_all' ,
361+ aliases = ['clean-all' ],
360362 help = 'Delete all builds, dists and caches' ,
361363 parents = [generic_parser ])
362- parser_clean_dists = add_parser (subparsers ,
364+ parser_clean_dists = add_parser (
365+ subparsers ,
363366 'clean_dists' , aliases = ['clean-dists' ],
364367 help = 'Delete all dists' ,
365368 parents = [generic_parser ])
366- parser_clean_bootstrap_builds = add_parser (subparsers ,
369+ parser_clean_bootstrap_builds = add_parser (
370+ subparsers ,
367371 'clean_bootstrap_builds' , aliases = ['clean-bootstrap-builds' ],
368372 help = 'Delete all bootstrap builds' ,
369373 parents = [generic_parser ])
370- parser_clean_builds = add_parser (subparsers ,
374+ parser_clean_builds = add_parser (
375+ subparsers ,
371376 'clean_builds' , aliases = ['clean-builds' ],
372377 help = 'Delete all builds' ,
373378 parents = [generic_parser ])
374379
380+ parser_clean = add_parser (subparsers , 'clean' ,
381+ help = 'Delete build components.' ,
382+ parents = [generic_parser ])
383+ parser_clean .add_argument (
384+ 'component' , nargs = '+' ,
385+ help = ('The build component(s) to delete. You can pass any '
386+ 'number of arguments from "all", "builds", "dists", '
387+ '"distributions", "bootstrap_builds", "downloads".' ))
388+
375389 parser_clean_recipe_build = add_parser (subparsers ,
376390 'clean_recipe_build' , aliases = ['clean-recipe-build' ],
377391 help = ('Delete the build components of the given recipe. '
@@ -561,6 +575,24 @@ def bootstraps(self, args):
561575 print (' {Fore.GREEN}depends: {bs.recipe_depends}{Fore.RESET}'
562576 .format (bs = bs , Fore = Out_Fore ))
563577
578+ def clean (self , args ):
579+ components = args .component
580+
581+ component_clean_methods = {'all' : self .clean_all ,
582+ 'dists' : self .clean_dists ,
583+ 'distributions' : self .clean_dists ,
584+ 'builds' : self .clean_builds ,
585+ 'bootstrap_builds' : self .clean_bootstrap_builds ,
586+ 'downloads' : self .clean_download_cache }
587+
588+ for component in components :
589+ if component not in component_clean_methods :
590+ raise ValueError ((
591+ 'Asked to clean "{}" but this argument is not '
592+ 'recognised' .format (component )))
593+ component_clean_methods [component ](args )
594+
595+
564596 def clean_all (self , args ):
565597 '''Delete all build components; the package cache, package builds,
566598 bootstrap builds and distributions.'''
0 commit comments