Commit 99085b30 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Make sure user and history commands work fine

Refs: #3934
parent 844a6bdb
......@@ -69,6 +69,7 @@ class Shell(Cmd):
_prompt_stack = []
_parser = None
auth_base = None
cloud = None
undoc_header = 'interactive shell commands:'
......@@ -202,7 +203,9 @@ class Shell(Cmd):
cmd_tree=self.cmd_tree)
else:
instance = cls(
dict(cmd_parser.arguments), self.auth_base)
dict(cmd_parser.arguments),
self.auth_base,
self.cloud)
cmd_parser.update_arguments(instance.arguments)
cmd_parser.arguments = instance.arguments
cmd_parser.syntax = '%s %s' % (
......
......@@ -50,7 +50,7 @@ class generic(object):
if _debug:
print_stack()
print_exc(e)
if isinstance(e, CLIError):
if isinstance(e, CLIError) or isinstance(e, ClientError):
raiseCLIError(e)
raiseCLIError(e, details=['%s, -d for debug info' % type(e)])
return _raise
......
......@@ -75,7 +75,7 @@ class _init_history(_command_init):
@errors.generic.all
@errors.history.init
def _run(self):
self.history = History(self.config.get('history', 'file'))
self.history = History(self.config.get_global('history_file'))
def main(self):
self._run()
......
......@@ -48,12 +48,14 @@ class History(object):
return True
def get(self, match_terms=None, limit=0):
f = open(self.filepath, 'r')
result = ['%s. \t%s' % (
i + 1, line) for i, line in enumerate(f.readlines())
if self._match(line, match_terms)]
offset = len(result) - limit if limit and len(result) > limit else 0
return result[offset:]
print 'HER?', self.filepath
with open(self.filepath, 'r') as f:
result = ['%s. \t%s' % (
i + 1, line) for i, line in enumerate(f.readlines())
if self._match(line, match_terms)]
offset = len(result) - limit if (
limit and len(result) > limit) else 0
return result[offset:]
def add(self, line):
f = open(self.filepath, 'a+')
......
......@@ -96,7 +96,7 @@ def run(remote_base, cloud, parser, _help):
exit(0)
cls = cmd.get_class()
executable = cls(parser.arguments, remote_base)
executable = cls(parser.arguments, remote_base, cloud)
parser.update_arguments(executable.arguments)
#parsed, unparsed = parse_known_args(parser, executable.arguments)
for term in _best_match:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment