Mercurial > libervia-backend
changeset 2354:5129a0506739
jp (shell): fixed use of profile + added EOF handling:
- main profile (i.e. the one specified on command line when invocating "jp shell") was not used. It is now added to arguments if the value is not overriden on command line or in use
- EOF (i.e. when user press C-d) is now understood as "quit" command
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Sep 2017 07:58:10 +0200 |
parents | ebc0dfe9c0ca |
children | 0fed4a1c033a |
files | frontends/src/jp/arg_tools.py frontends/src/jp/cmd_shell.py |
diffstat | 2 files changed, 21 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/jp/arg_tools.py Fri Sep 08 07:58:08 2017 +0200 +++ b/frontends/src/jp/arg_tools.py Fri Sep 08 07:58:10 2017 +0200 @@ -89,7 +89,7 @@ value=escape(value))) else: if verbose: - host.disp(_(u'arg {name}={value} set (in USE)').format(name=arg, value=escape(value))) + host.disp(_(u'arg {name}={value} (in USE)').format(name=arg, value=escape(value))) if not action.option_strings: pos_args.append(value) else:
--- a/frontends/src/jp/cmd_shell.py Fri Sep 08 07:58:08 2017 +0200 +++ b/frontends/src/jp/cmd_shell.py Fri Sep 08 07:58:10 2017 +0200 @@ -34,7 +34,7 @@ This enrironment helps you using several {app_name} commands with similar parameters. -To quit, just enter "quit" or press C-c. +To quit, just enter "quit" or press C-d. Enter "help" or "?" to know what to do """).format(app_name = C.APP_NAME) @@ -122,6 +122,8 @@ will launch the command with args on the line (i.e. will launch do [args]) """ + if args=='EOF': + self.do_quit('') self.do_do(args) def do_help(self, args): @@ -180,11 +182,25 @@ def do_do(self, args): """lauch a command""" args = self.parse_args(args) + if (self._not_default_profile and + not '-p' in args and + not '--profile' in args and + not 'profile' in self.use): + # profile is not specified and we are not using the default profile + # so we need to add it in arguments to use current user profile + if self.verbose: + self.disp(_(u'arg profile={profile} (logged profile)').format(profile=self.profile)) + use = self.use.copy() + use['profile'] = self.profile + else: + use = self.use + + # args may be modified by use_args # to remove subparsers from it parser_args, use_args = arg_tools.get_use_args(self.host, args, - self.use, + use, verbose=self.verbose, parser=self._cur_parser ) @@ -238,6 +254,8 @@ self.do_quit(args) def start(self): + default_profile = self.host.bridge.profileNameGet(C.PROF_KEY_DEFAULT) + self._not_default_profile = self.profile != default_profile self.path = [] self._cur_parser = self.host.parser self.use = {}