3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00

[Doxygen] Switch to using argparse to parse command line arguments

in `mk_api_doc.py`. Given that we need to add a bunch of new command
line options it makes sense to use a less clumsy and concise API.
This commit is contained in:
Dan Liew 2017-04-24 16:24:15 +01:00
parent ca678c3675
commit 2cdb45605d

View file

@ -1,5 +1,9 @@
# Copyright (c) Microsoft Corporation 2015 # Copyright (c) Microsoft Corporation 2015
"""
Z3 API documentation generator script
"""
import argparse
import os import os
import shutil import shutil
import re import re
@ -12,39 +16,23 @@ import shutil
ML_ENABLED=False ML_ENABLED=False
BUILD_DIR='../build' BUILD_DIR='../build'
def display_help(exit_code):
assert isinstance(exit_code, int)
print("mk_api_doc.py: Z3 documentation generator\n")
print("\nOptions:")
print(" -h, --help display this message.")
print(" -b <subdir>, --build=<subdir> subdirectory where Z3 is built (default: ../build).")
print(" --ml include ML/OCaml API documentation.")
sys.exit(exit_code)
def parse_options(): def parse_options():
global ML_ENABLED, BUILD_DIR global ML_ENABLED, BUILD_DIR
parser = argparse.ArgumentParser(description=__doc__)
try: parser.add_argument('-b',
options, remainder = getopt.gnu_getopt(sys.argv[1:], '--build',
'b:h', default=BUILD_DIR,
['build=', 'help', 'ml']) help='Directory where Z3 is built (default: %(default)s)',
except: )
print("ERROR: Invalid command line option") parser.add_argument('--ml',
display_help(1) action='store_true',
default=False,
for opt, arg in options: help='Include ML/OCaml API documentation'
if opt in ('-b', '--build'): )
BUILD_DIR = mk_util.norm_path(arg) pargs = parser.parse_args()
elif opt in ('h', '--help'): ML_ENABLED = pargs.ml
display_help(0) BUILD_DIR = pargs.build
elif opt in ('--ml'): return
ML_ENABLED=True
else:
print("ERROR: Invalid command line option: %s" % opt)
display_help(1)
def mk_dir(d): def mk_dir(d):
if not os.path.exists(d): if not os.path.exists(d):