# HG changeset patch # User Goffi # Date 1504850290 -7200 # Node ID 5129a0506739a394f0c3d5e54d2674f309508038 # Parent ebc0dfe9c0ca3c9411c5ed44522717a67bef65f2 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 diff -r ebc0dfe9c0ca -r 5129a0506739 frontends/src/jp/arg_tools.py --- 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: diff -r ebc0dfe9c0ca -r 5129a0506739 frontends/src/jp/cmd_shell.py --- 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 = {}