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
65b8765b
Commit
65b8765b
authored
Dec 14, 2012
by
Stavros Sachtouris
Browse files
Merge branch 'features/output' into develop
parents
93c22870
53254b46
Changes
1
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/command_shell.py
View file @
65b8765b
...
...
@@ -64,7 +64,7 @@ def _init_shell(exe_string, parser):
class
Shell
(
Cmd
):
"""Kamaki interactive shell"""
_prefix
=
'['
_suffix
=
']:'
_suffix
=
']:
'
cmd_tree
=
None
_history
=
None
_context_stack
=
[]
...
...
@@ -77,13 +77,15 @@ class Shell(Cmd):
if
self
.
_context_stack
:
self
.
_roll_command
()
self
.
_restore
(
self
.
_context_stack
.
pop
())
self
.
set_prompt
(
self
.
_prompt_stack
.
pop
()[
1
:
-
2
])
self
.
set_prompt
(
self
.
_prompt_stack
.
pop
()[
len
(
self
.
_prefix
):
-
len
(
self
.
_suffix
)])
return
Cmd
.
postcmd
(
self
,
post
,
line
)
def
precmd
(
self
,
line
):
if
line
.
startswith
(
'/'
):
cur_cmd_path
=
self
.
prompt
.
replace
(
' '
,
'_'
)[
1
:
-
2
]
cur_cmd_path
=
self
.
prompt
.
replace
(
' '
,
'_'
)[
len
(
self
.
_prefix
):
-
len
(
self
.
_suffix
)]
if
cur_cmd_path
!=
self
.
cmd_tree
.
name
:
cur_cmd
=
self
.
cmd_tree
.
get_command
(
cur_cmd_path
)
self
.
_context_stack
.
append
(
self
.
_backup
())
...
...
@@ -101,11 +103,12 @@ class Shell(Cmd):
%
version
)
def
set_prompt
(
self
,
new_prompt
):
self
.
prompt
=
'
[%s]:'
%
new_prompt
self
.
prompt
=
'
%s%s%s'
%
(
self
.
_prefix
,
new_prompt
,
self
.
_suffix
)
def
do_exit
(
self
,
line
):
print
(
''
)
if
self
.
prompt
[
1
:
-
2
]
==
self
.
cmd_tree
.
name
:
if
self
.
prompt
[
len
(
self
.
_prefix
):
-
len
(
self
.
_suffix
)]
\
==
self
.
cmd_tree
.
name
:
exit
(
0
)
return
True
...
...
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