Add command-line options to change default builtins and SEF table files.

This commit is contained in:
Sei Lisa 2017-04-28 23:43:15 +02:00
parent 2d78239d23
commit 0af2349ef9
2 changed files with 23 additions and 6 deletions

17
main.py
View file

@ -172,6 +172,8 @@ Usage: {progname}
[-h|--help] print this help
[--version] print this program's version
[-o|--output=<filename>] output to file rather than stdout
[-b|--builtins=<filename>] use a builtins file other than builtins.txt
[-S|--seftable=<filename>] use a SEF table file other than seftable.txt
[-H|--header] add the script as a comment in Firestorm format
[-T|--timestamp] add a timestamp as a comment at the beginning
[-y|--python-exceptions] when an exception is raised, show a stack trace
@ -343,11 +345,12 @@ def main(argv):
% (b"', '".join(options - validoptions)).decode('utf8'))
try:
opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTy',
opts, args = getopt.gnu_getopt(argv[1:], 'hO:o:p:P:HTyb:S:',
('optimizer-options=', 'help', 'version', 'output=', 'header',
'timestamp','python-exceptions',
'preproc=', 'precmd=', 'prearg=', 'prenodef', 'preshow',
'avid=', 'avname=', 'assetid=', 'shortname='))
'avid=', 'avname=', 'assetid=', 'shortname=', 'builtins='
'seftable='))
except getopt.GetoptError as e:
Usage(argv[0])
sys.stderr.write(u"\nError: " + str(e).decode('utf8') + u"\n")
@ -366,6 +369,8 @@ def main(argv):
mcpp_mode = False
preshow = False
raise_exception = False
builtins = None
seftable = None
for opt, arg in opts:
if type(opt) is unicode:
@ -409,6 +414,12 @@ def main(argv):
elif opt in ('-o', '--output'):
outfile = arg
elif opt in ('-b', '--builtins'):
builtins = arg
elif opt in ('-S', '--seftable'):
seftable = arg
elif opt in ('-y', '--python-exceptions'):
raise_exception = True
@ -597,7 +608,7 @@ def main(argv):
if not preshow:
p = parser()
p = parser(builtins, seftable)
try:
ts = p.parse(script, options)
except EParse as e: