diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-02 16:55:39 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-02 16:55:39 +0200 |
commit | ba77e0dbbd5879e72353af65450a78e0fc554dad (patch) | |
tree | 389af535b27240fb69e6213805146c9506a00c92 /mesonconf.py | |
parent | b82584641a430fdd1629ed69c845e66854539f8a (diff) | |
download | meson-ba77e0dbbd5879e72353af65450a78e0fc554dad.zip meson-ba77e0dbbd5879e72353af65450a78e0fc554dad.tar.gz meson-ba77e0dbbd5879e72353af65450a78e0fc554dad.tar.bz2 |
Use argparse in mesonconf.py.
Diffstat (limited to 'mesonconf.py')
-rwxr-xr-x | mesonconf.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/mesonconf.py b/mesonconf.py index 24cf576..2041841 100755 --- a/mesonconf.py +++ b/mesonconf.py @@ -16,16 +16,15 @@ import sys, os import pickle -from optparse import OptionParser +import argparse import coredata, optinterpreter from meson import build_types -usage_info = '%prog [build dir] [set commands]' +parser = argparse.ArgumentParser() -parser = OptionParser(usage=usage_info, version=coredata.version) - -parser.add_option('-D', action='append', default=[], dest='sets', +parser.add_argument('-D', action='append', default=[], dest='sets', help='Set an option to the given value.') +parser.add_argument('directory', nargs='+') class ConfException(Exception): def __init__(self, *args, **kwargs): @@ -198,16 +197,16 @@ class Conf: self.print_aligned(optarr) if __name__ == '__main__': - (options, args) = parser.parse_args(sys.argv) - if len(args) > 2: + options = parser.parse_args() + if len(options.directory) > 1: print(args) print('%s <build directory>' % sys.argv[0]) print('If you omit the build directory, the current directory is substituted.') sys.exit(1) - if len(args) == 1: + if len(options.directory) == 0: builddir = os.getcwd() else: - builddir = args[-1] + builddir = options.directory[0] try: c = Conf(builddir) if len(options.sets) > 0: |