diff frontends/src/jp/cmd_profile.py @ 1403:f913b09cd9cc

jp (profile): in "profile create", jid and password arguments are now optional + added a new --xmpp-password option to set XMPP password separately (default to the same password as for profile).
author Goffi <goffi@goffi.org>
date Mon, 06 Apr 2015 17:36:21 +0200
parents 391b0c21f4be
children e4e960d285b0
line wrap: on
line diff
--- a/frontends/src/jp/cmd_profile.py	Mon Apr 06 17:32:28 2015 +0200
+++ b/frontends/src/jp/cmd_profile.py	Mon Apr 06 17:36:21 2015 +0200
@@ -93,12 +93,17 @@
 
     def add_parser_options(self):
         self.parser.add_argument('profile', type=str, help=_('the name of the profile'))
-        self.parser.add_argument('jid', type=str, help=_('the jid of the profile'))
-        self.parser.add_argument('password', type=str, help=_('the password of the profile'))
+        self.parser.add_argument('-p', '--password', type=str, default='', help=_('the password of the profile'))
+        self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile'))
+        self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account (use profile password if not specified)'),
+                                 metavar='PASSWORD')
 
     def _profile_created(self):
-        self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile)
-        self.host.bridge.setParam("Password", self.args.password, "Connection", profile_key=self.args.profile)
+        if self.args.jid:
+            self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile)
+        xmpp_pwd = self.args.password or self.args.xmpp_password
+        if xmpp_pwd:
+            self.host.bridge.setParam("Password", xmpp_pwd, "Connection", profile_key=self.args.profile)
         self.host.quit()
 
     def run(self):
@@ -107,7 +112,7 @@
         if self.args.profile in self.host.bridge.getProfilesList():
             error("Profile %s already exists." % self.args.profile)
             self.host.quit(1)
-        self.host.bridge.asyncCreateProfile(self.args.profile, callback=self._profile_created, errback=None)
+        self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None)
 
 
 class Profile(base.CommandBase):