exit gracefully on ctrlc
This commit is contained in:
parent
7fd6b6ab51
commit
7038e8f852
@ -87,11 +87,13 @@ class CommandLine:
|
||||
p = self.prompt()
|
||||
try:
|
||||
c = input(p)
|
||||
except EOFError:
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
self.handle_eof()
|
||||
break
|
||||
try:
|
||||
self.handle_cmd(c)
|
||||
except Exception as e:
|
||||
except KeyboardInterrupt:
|
||||
print("Interrupted")
|
||||
except (Exception) as e:
|
||||
logging.error(e, exc_info=True)
|
||||
|
||||
|
@ -24,6 +24,10 @@ class Commander(CommandLine):
|
||||
self.stop_auto= False
|
||||
super().__init__()
|
||||
|
||||
def handle_eof(self):
|
||||
self.store.close()
|
||||
print("Goodbye!")
|
||||
|
||||
def prompt(self):
|
||||
if self.ship:
|
||||
return f'{self.ship.symbol}> '
|
||||
|
Loading…
Reference in New Issue
Block a user