jp (profile): added confirmation and --force arguement to profile/delete
This commit is contained in:
parent
fea3296b89
commit
5a81941c33
1 changed files with 8 additions and 0 deletions
|
|
@ -58,12 +58,20 @@ class ProfileDelete(base.CommandBase):
|
|||
|
||||
def add_parser_options(self):
|
||||
self.parser.add_argument('profile', type=str, help=PROFILE_HELP)
|
||||
self.parser.add_argument('-f', '--force', action='store_true', help=_(u'delete profile without confirmation'))
|
||||
|
||||
def run(self):
|
||||
super(ProfileDelete, self).run()
|
||||
if self.args.profile not in self.host.bridge.getProfilesList():
|
||||
log.error("Profile %s doesn't exist." % self.args.profile)
|
||||
self.host.quit(1)
|
||||
message = u"Are you sure to delete profile [{}] ?".format(self.args.profile)
|
||||
if not self.args.force:
|
||||
res = raw_input("{} (y/N)? ".format(message))
|
||||
if res not in ("y", "Y"):
|
||||
self.disp(_(u"Profile deletion cancelled"))
|
||||
self.host.quit(2)
|
||||
|
||||
self.host.bridge.asyncDeleteProfile(self.args.profile, callback=lambda dummy: None)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue