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
This commit is contained in:
parent
e33d68bcf1
commit
15ff6aedf4
2 changed files with 21 additions and 3 deletions
|
|
@ -89,7 +89,7 @@ def get_use_args(host, args, use, verbose=False, parser=None):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ INTRO = _(u"""Welcome to {app_name} shell, the Salut à Toi shell !
|
|||
|
||||
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 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
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 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
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 @@ class Shell(base.CommandBase, cmd.Cmd):
|
|||
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 = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue