40 |
40 |
from kamaki.cli import command
|
41 |
41 |
from kamaki.cli.commands import _command_init
|
42 |
42 |
from kamaki.cli import _exec_cmd, _print_error_message
|
43 |
|
from kamaki.cli.errors import CLIError
|
|
43 |
from kamaki.cli.errors import CLIError, raiseCLIError
|
44 |
44 |
from kamaki.cli.utils import split_input
|
45 |
45 |
from kamaki.clients import ClientError
|
46 |
46 |
|
... | ... | |
82 |
82 |
|
83 |
83 |
|
84 |
84 |
@command(history_cmds)
|
85 |
|
class history_recall(_init_history):
|
|
85 |
class history_load(_init_history):
|
86 |
86 |
"""Re-call a previously called command"""
|
87 |
87 |
|
88 |
88 |
_cmd_tree = None
|
... | ... | |
111 |
111 |
print('Execution of [ %s ] failed' % line)
|
112 |
112 |
print('\t%s' % e)
|
113 |
113 |
|
114 |
|
def main(self, commandid):
|
|
114 |
def _get_cmd_ids(self, cmd_ids):
|
|
115 |
cmd_id_list = []
|
|
116 |
for cmd_str in cmd_ids:
|
|
117 |
num1, sep, num2 = cmd_str.partition('-')
|
|
118 |
try:
|
|
119 |
if sep:
|
|
120 |
for i in range(int(num1), int(num2) + 1):
|
|
121 |
cmd_id_list.append(i)
|
|
122 |
else:
|
|
123 |
cmd_id_list.append(int(cmd_str))
|
|
124 |
except ValueError:
|
|
125 |
raiseCLIError('Invalid history id %s' % cmd_str)
|
|
126 |
return cmd_id_list
|
|
127 |
|
|
128 |
def main(self, *command_ids):
|
115 |
129 |
super(self.__class__, self).main()
|
116 |
|
r = self.history.retrieve(commandid)
|
117 |
|
print(r[:-1])
|
118 |
|
if self._cmd_tree:
|
119 |
|
r = r[len('kamaki '):-1] if r.startswith('kamaki ') else r[:-1]
|
120 |
|
self._run_from_line(r)
|
|
130 |
cmd_list = self._get_cmd_ids(command_ids)
|
|
131 |
for cmd_id in cmd_list:
|
|
132 |
r = self.history.retrieve(cmd_id)
|
|
133 |
print(r[:-1])
|
|
134 |
if self._cmd_tree:
|
|
135 |
r = r[len('kamaki '):-1] if r.startswith('kamaki ') else r[:-1]
|
|
136 |
self._run_from_line(r)
|