1
0
Fork 0

manage exiting without external dependency

This commit is contained in:
Kevin Matz 2018-10-25 14:56:58 -04:00
parent 1aaf12b6f3
commit 999624bd49
1 changed files with 6 additions and 9 deletions

View File

@ -19,7 +19,6 @@ import antlr4
import configparser
import logging
import readline
import signal
import sys
from CommentMacroLexer import CommentMacroLexer
@ -58,20 +57,18 @@ def comment(text):
walker.walk(oscMacro, tree)
def orderly_exit():
logger.info('Goodbye.')
sys.exit(0)
if __name__ == '__main__':
signal.signal(signal.SIGINT, orderly_exit)
if len(sys.argv) > 1:
logger.debug("found macro at argv[1]")
comment(sys.argv[1])
else:
while True:
text = input("comment# ")
try:
text = input("comment# ")
except KeyboardInterrupt:
print()
sys.exit(0)
if text == 'exit':
orderly_exit()
sys.exit(0)
else:
comment(text)