Revision 3185cd6d kamaki/cli/commands/history.py
b/kamaki/cli/commands/history.py | ||
---|---|---|
41 | 41 |
from kamaki.cli.commands import _command_init, errors |
42 | 42 |
from kamaki.cli import exec_cmd, print_error_message |
43 | 43 |
from kamaki.cli.errors import CLIError, raiseCLIError |
44 |
from kamaki.cli.utils import split_input |
|
44 |
from kamaki.cli.utils import split_input, print_list
|
|
45 | 45 |
from kamaki.clients import ClientError |
46 | 46 |
|
47 | 47 |
|
... | ... | |
111 | 111 |
ret = self.history.get(match_terms=self['match'], limit=self['limit']) |
112 | 112 |
|
113 | 113 |
if not cmd_ids: |
114 |
print(''.join(ret))
|
|
114 |
print_list(ret, out=self._out)
|
|
115 | 115 |
return |
116 | 116 |
|
117 | 117 |
num_list = [] |
... | ... | |
122 | 122 |
try: |
123 | 123 |
cur_id = int(cmd_id) |
124 | 124 |
if cur_id: |
125 |
print(ret[cur_id - (1 if cur_id > 0 else 0)][:-1])
|
|
125 |
self.writeln(ret[cur_id - (1 if cur_id > 0 else 0)][:-1])
|
|
126 | 126 |
except IndexError as e2: |
127 | 127 |
raiseCLIError(e2, 'Command id out of 1-%s range' % len(ret)) |
128 | 128 |
|
... | ... | |
184 | 184 |
prs.parse(args) |
185 | 185 |
exec_cmd(instance, prs.unparsed, prs.parser.print_help) |
186 | 186 |
except (CLIError, ClientError) as err: |
187 |
print_error_message(err) |
|
187 |
print_error_message(err, self._err)
|
|
188 | 188 |
except Exception as e: |
189 |
print('Execution of [ %s ] failed' % line) |
|
190 |
print('\t%s' % e) |
|
189 |
self.error('Execution of [ %s ] failed\n\t%s' % (line, e)) |
|
191 | 190 |
|
192 | 191 |
@errors.generic.all |
193 | 192 |
@errors.history._get_cmd_ids |
... | ... | |
203 | 202 |
for cmd_id in cmd_list: |
204 | 203 |
r = self.history.retrieve(cmd_id) |
205 | 204 |
try: |
206 |
print('< %s >' % r[:-1])
|
|
205 |
self.writeln('< %s >' % r[:-1])
|
|
207 | 206 |
except (TypeError, KeyError): |
208 | 207 |
continue |
209 | 208 |
if self._cmd_tree: |
Also available in: Unified diff