@@ -352,26 +352,40 @@ def add_parser(subparsers, *args, **kwargs):
352
352
"--compact" , action = "store_true" , default = False ,
353
353
help = "Produce a compact list suitable for scripting" )
354
354
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' ,
357
358
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' ],
360
362
help = 'Delete all builds, dists and caches' ,
361
363
parents = [generic_parser ])
362
- parser_clean_dists = add_parser (subparsers ,
364
+ parser_clean_dists = add_parser (
365
+ subparsers ,
363
366
'clean_dists' , aliases = ['clean-dists' ],
364
367
help = 'Delete all dists' ,
365
368
parents = [generic_parser ])
366
- parser_clean_bootstrap_builds = add_parser (subparsers ,
369
+ parser_clean_bootstrap_builds = add_parser (
370
+ subparsers ,
367
371
'clean_bootstrap_builds' , aliases = ['clean-bootstrap-builds' ],
368
372
help = 'Delete all bootstrap builds' ,
369
373
parents = [generic_parser ])
370
- parser_clean_builds = add_parser (subparsers ,
374
+ parser_clean_builds = add_parser (
375
+ subparsers ,
371
376
'clean_builds' , aliases = ['clean-builds' ],
372
377
help = 'Delete all builds' ,
373
378
parents = [generic_parser ])
374
379
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
+
375
389
parser_clean_recipe_build = add_parser (subparsers ,
376
390
'clean_recipe_build' , aliases = ['clean-recipe-build' ],
377
391
help = ('Delete the build components of the given recipe. '
@@ -561,6 +575,24 @@ def bootstraps(self, args):
561
575
print (' {Fore.GREEN}depends: {bs.recipe_depends}{Fore.RESET}'
562
576
.format (bs = bs , Fore = Out_Fore ))
563
577
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
+
564
596
def clean_all (self , args ):
565
597
'''Delete all build components; the package cache, package builds,
566
598
bootstrap builds and distributions.'''
0 commit comments