Split disconnect and exit commands

This commit is contained in:
Bridget
2020-04-12 23:11:28 +02:00
parent eb831ebdcd
commit c6f001cef6

View File

@@ -67,6 +67,13 @@ class Shell(cmd.Cmd):
def do_exit(self, arg):
"""Exit the shell."""
print("")
if self.url:
self.do_disconnect(None)
return True
def do_disconnect(self, arg):
"""Disconnect from remote."""
if self.url:
result = self.send_cmd(self.url, "disconnect")
if result.get("result") == "disconnected":
@@ -74,7 +81,9 @@ class Shell(cmd.Cmd):
else:
print("Disconnected from remote (without acknowledgement).")
return True
url = None
else:
print("Error: Not connected to remote.")
def add_cmd(self, name, help_text):
"""Make a new command available within the shell."""