mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
cli: Handle command breaks, ctrl+c, don't break the shell
- Fix handles shell loop - Handles any control breaks without breaking the shell - Handles ctrl+c to start afresh on the shell Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
parent
c8926de018
commit
1551b982c4
@ -65,7 +65,7 @@ logger = logging.getLogger(__name__)
|
||||
completions = cloudstackAPI.__all__
|
||||
|
||||
|
||||
class CloudStackShell(cmd.Cmd):
|
||||
class CloudStackShell(cmd.Cmd, object):
|
||||
intro = ("☁ Apache CloudStack 🐵 cloudmonkey " + __version__ +
|
||||
". Type help or ? to list commands.\n")
|
||||
ruler = "="
|
||||
@ -133,6 +133,15 @@ class CloudStackShell(cmd.Cmd):
|
||||
def emptyline(self):
|
||||
pass
|
||||
|
||||
def cmdloop(self, intro=None):
|
||||
print self.intro
|
||||
while True:
|
||||
try:
|
||||
super(CloudStackShell, self).cmdloop(intro = "")
|
||||
self.postloop()
|
||||
except KeyboardInterrupt:
|
||||
print("^C")
|
||||
|
||||
def print_shell(self, *args):
|
||||
try:
|
||||
for arg in args:
|
||||
@ -273,7 +282,6 @@ class CloudStackShell(cmd.Cmd):
|
||||
x.partition("=")[2]],
|
||||
args[1:])[x] for x in range(len(args) - 1))
|
||||
|
||||
# FIXME: With precaching, dynamic loading can be removed
|
||||
api_cmd_str = "%sCmd" % api_name
|
||||
api_mod = self.get_api_module(api_name, [api_cmd_str])
|
||||
if api_mod is None:
|
||||
@ -466,7 +474,7 @@ class CloudStackShell(cmd.Cmd):
|
||||
"""
|
||||
Quit on Ctrl+d or EOF
|
||||
"""
|
||||
return True
|
||||
sys.exit()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user