@@ -48,10 +48,16 @@ class ProjectCleanup(command.Command):
4848
4949 def get_parser (self , prog_name ):
5050 parser = super (ProjectCleanup , self ).get_parser (prog_name )
51- parser .add_argument (
51+ action_group = parser .add_mutually_exclusive_group ()
52+ action_group .add_argument (
5253 '--dry-run' ,
5354 action = 'store_true' ,
54- help = _ ("List a project's resources" )
55+ help = _ ("List a project's resources but do not delete them" )
56+ )
57+ action_group .add_argument (
58+ '--auto-approve' ,
59+ action = 'store_true' ,
60+ help = _ ("Delete resources without asking for confirmation" )
5561 )
5662 project_group = parser .add_mutually_exclusive_group (required = True )
5763 project_group .add_argument (
@@ -67,12 +73,12 @@ def get_parser(self, prog_name):
6773 parser .add_argument (
6874 '--created-before' ,
6975 metavar = '<YYYY-MM-DDTHH24:MI:SS>' ,
70- help = _ ('Drop resources created before the given time' )
76+ help = _ ('Only delete resources created before the given time' )
7177 )
7278 parser .add_argument (
7379 '--updated-before' ,
7480 metavar = '<YYYY-MM-DDTHH24:MI:SS>' ,
75- help = _ ('Drop resources updated before the given time' )
81+ help = _ ('Only delete resources updated before the given time' )
7682 )
7783 identity_common .add_project_domain_option_to_parser (parser )
7884 return parser
@@ -127,12 +133,13 @@ def take_action(self, parsed_args):
127133 if parsed_args .dry_run :
128134 return
129135
130- confirm = ask_user_yesno (
131- _ ("These resources will be deleted. Are you sure" ))
136+ if not parsed_args .auto_approve :
137+ if not ask_user_yesno (
138+ _ ("These resources will be deleted. Are you sure" )):
139+ return
132140
133- if confirm :
134- self .log .warning (_ ('Deleting resources' ))
141+ self .log .warning (_ ('Deleting resources' ))
135142
136- project_connect .project_cleanup (dry_run = False ,
137- status_queue = status_queue ,
138- filters = filters )
143+ project_connect .project_cleanup (dry_run = False ,
144+ status_queue = status_queue ,
145+ filters = filters )
0 commit comments