git @ Cat's Eye Technologies SixtyPical / dbba7cc
Use ArgumentParser instead of OptionParser. Chris Pressey 3 years ago
1 changed file(s) with 35 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
1212 # ----------------------------------------------------------------- #
1313
1414 import codecs
15 from optparse import OptionParser
15 from argparse import ArgumentParser
1616 from pprint import pprint
1717 import sys
1818 import traceback
2424
2525
2626 if __name__ == '__main__':
27 optparser = OptionParser(__doc__.strip())
27 argparser = ArgumentParser(__doc__.strip())
2828
29 optparser.add_option("--analyze-only",
30 action="store_true",
31 help="Only parse and analyze the program; do not compile it.")
32 optparser.add_option("--basic-prelude",
33 action="store_true",
34 help="Insert a Commodore BASIC 2.0 snippet before the program "
35 "so that it can be LOADed and RUN on Commodore platforms.")
36 optparser.add_option("--debug",
37 action="store_true",
38 help="Display debugging information when analyzing and compiling.")
39 optparser.add_option("--parse-only",
40 action="store_true",
41 help="Only parse the program; do not analyze or compile it.")
42 optparser.add_option("--traceback",
43 action="store_true",
44 help="When an error occurs, display a full Python traceback.")
29 argparser.add_argument(
30 'filenames', metavar='FILENAME', type=str, nargs='+',
31 help="The SixtyPical source files to compile."
32 )
33 argparser.add_argument(
34 "--analyze-only",
35 action="store_true",
36 help="Only parse and analyze the program; do not compile it."
37 )
38 argparser.add_argument(
39 "--basic-prelude",
40 action="store_true",
41 help="Insert a Commodore BASIC 2.0 snippet before the program "
42 "so that it can be LOADed and RUN on Commodore platforms."
43 )
44 argparser.add_argument(
45 "--debug",
46 action="store_true",
47 help="Display debugging information when analyzing and compiling."
48 )
49 argparser.add_argument(
50 "--parse-only",
51 action="store_true",
52 help="Only parse the program; do not analyze or compile it."
53 )
54 argparser.add_argument(
55 "--traceback",
56 action="store_true",
57 help="When an error occurs, display a full Python traceback."
58 )
4559
46 (options, args) = optparser.parse_args(sys.argv[1:])
60 options, unknown = argparser.parse_known_args(sys.argv[1:])
61 remainder = ' '.join(unknown)
4762
48 for filename in args:
63 for filename in options.filenames:
4964 text = open(filename).read()
5065
5166 try: