1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-22 01:32:13 +00:00

Use ArgumentParser instead of OptionParser.

This commit is contained in:
Chris Pressey 2018-03-06 16:28:34 +00:00
parent 8298ad38f9
commit dbba7cc7b9

View File

@ -13,7 +13,7 @@ sys.path.insert(0, join(dirname(realpath(sys.argv[0])), '..', 'src'))
# ----------------------------------------------------------------- #
import codecs
from optparse import OptionParser
from argparse import ArgumentParser
from pprint import pprint
import sys
import traceback
@ -25,28 +25,43 @@ from sixtypical.compiler import Compiler
if __name__ == '__main__':
optparser = OptionParser(__doc__.strip())
argparser = ArgumentParser(__doc__.strip())
optparser.add_option("--analyze-only",
action="store_true",
help="Only parse and analyze the program; do not compile it.")
optparser.add_option("--basic-prelude",
action="store_true",
help="Insert a Commodore BASIC 2.0 snippet before the program "
"so that it can be LOADed and RUN on Commodore platforms.")
optparser.add_option("--debug",
action="store_true",
help="Display debugging information when analyzing and compiling.")
optparser.add_option("--parse-only",
action="store_true",
help="Only parse the program; do not analyze or compile it.")
optparser.add_option("--traceback",
action="store_true",
help="When an error occurs, display a full Python traceback.")
argparser.add_argument(
'filenames', metavar='FILENAME', type=str, nargs='+',
help="The SixtyPical source files to compile."
)
argparser.add_argument(
"--analyze-only",
action="store_true",
help="Only parse and analyze the program; do not compile it."
)
argparser.add_argument(
"--basic-prelude",
action="store_true",
help="Insert a Commodore BASIC 2.0 snippet before the program "
"so that it can be LOADed and RUN on Commodore platforms."
)
argparser.add_argument(
"--debug",
action="store_true",
help="Display debugging information when analyzing and compiling."
)
argparser.add_argument(
"--parse-only",
action="store_true",
help="Only parse the program; do not analyze or compile it."
)
argparser.add_argument(
"--traceback",
action="store_true",
help="When an error occurs, display a full Python traceback."
)
(options, args) = optparser.parse_args(sys.argv[1:])
options, unknown = argparser.parse_known_args(sys.argv[1:])
remainder = ' '.join(unknown)
for filename in args:
for filename in options.filenames:
text = open(filename).read()
try: