changeset 1861:3b2a236fa743

jp (profile): added confirmation and --force arguement to profile/delete
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:52:51 +0100 (2016-02-29)
parents afc7f6328394
children 6d9c87bdc452
files frontends/src/jp/cmd_profile.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_profile.py	Mon Feb 29 16:52:51 2016 +0100
+++ b/frontends/src/jp/cmd_profile.py	Mon Feb 29 16:52:51 2016 +0100
@@ -58,12 +58,20 @@
 
     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)