Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
cb123f78
Commit
cb123f78
authored
Dec 12, 2012
by
Stavros Sachtouris
Browse files
Merge branch 'features/history' into develop
parents
59cadffb
660a0dad
Changes
1
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/history_cli.py
View file @
cb123f78
...
...
@@ -56,7 +56,7 @@ class _init_history(_command_init):
@
command
(
history_cmds
)
class
history_show
(
_init_history
):
"""Show history [co
ntaining terms...
]"""
"""Show history [co
mmandid | <commandid1> - <commandid2>
]"""
def
__init__
(
self
,
arguments
=
{}):
super
(
self
.
__class__
,
self
).
__init__
(
arguments
)
...
...
@@ -65,11 +65,23 @@ class history_show(_init_history):
self
.
arguments
[
'match'
]
=
\
ValueArgument
(
'show lines that match all given terms'
,
'--match'
)
def
main
(
self
):
def
main
(
self
,
cmd_id
=
None
):
super
(
self
.
__class__
,
self
).
main
()
ret
=
self
.
history
.
get
(
match_terms
=
self
.
get_argument
(
'match'
),
limit
=
self
.
get_argument
(
'limit'
))
print
(
''
.
join
(
ret
))
if
cmd_id
:
num1
,
sep
,
num2
=
cmd_id
.
partition
(
'-'
)
try
:
num1
=
int
(
num1
)
-
1
num2
=
int
(
num2
)
if
sep
else
num1
for
i
in
range
(
num1
,
num2
):
print
(
ret
[
int
(
i
)][:
-
1
])
except
ValueError
as
e1
:
raiseCLIError
(
e1
,
'Invalid history id %s'
%
cmd_id
)
except
IndexError
as
e2
:
raiseCLIError
(
e2
,
'Command id out of 1-%s range'
%
len
(
ret
))
else
:
print
(
''
.
join
(
ret
))
@
command
(
history_cmds
)
...
...
@@ -125,7 +137,7 @@ class history_load(_init_history):
else
:
cmd_id_list
.
append
(
int
(
cmd_str
))
except
ValueError
:
raiseCLIError
(
'Invalid history id %s'
%
cmd_str
)
raiseCLIError
(
None
,
'Invalid history id %s'
%
cmd_str
)
return
cmd_id_list
def
main
(
self
,
*
command_ids
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment