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
99085b30
Commit
99085b30
authored
Jun 06, 2013
by
Stavros Sachtouris
Browse files
Make sure user and history commands work fine
Refs: #3934
parent
844a6bdb
Changes
5
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/command_shell.py
View file @
99085b30
...
...
@@ -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'
%
(
...
...
kamaki/cli/commands/errors.py
View file @
99085b30
...
...
@@ -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
...
...
kamaki/cli/commands/history.py
View file @
99085b30
...
...
@@ -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
()
...
...
kamaki/cli/history.py
View file @
99085b30
...
...
@@ -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+'
)
...
...
kamaki/cli/one_command.py
View file @
99085b30
...
...
@@ -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
:
...
...
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