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