1
0
Fork 0

move shell interpreter to own file

This commit is contained in:
Kevin Matz 2019-11-18 13:22:31 -05:00
parent 28c7abf62a
commit d414c8424c
2 changed files with 31 additions and 0 deletions

31
bs.py Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Interactive BaconScript shell.
"""
import sys
from bacon.script import comment
# handle user input if run directly
if __name__ == '__main__':
if len(sys.argv) > 1:
# look for macros passed as arguments
logger.debug("found macro at argv[1]")
comment(sys.argv[1])
else:
# for input history and line editing
import readline
# be an interactive shell
while True:
# get user input
try:
text = input("comment# ")
except (KeyboardInterrupt, EOFError):
text = 'exit'
print(text)
# catch exit keyword
if text.lower() == 'exit':
break
# exec user input
comment(text)

0
setup.py Normal file → Executable file
View File