diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-09-07 19:03:33 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-09-12 03:32:03 +0530 |
commit | b6723b3d7c57968fc4005f2143023c7e43753466 (patch) | |
tree | e189d950117407c33acf14431ab8459244edf269 | |
parent | 15c1f4396421d9404074e7f2caadb065ea39fa28 (diff) | |
download | meson-b6723b3d7c57968fc4005f2143023c7e43753466.zip meson-b6723b3d7c57968fc4005f2143023c7e43753466.tar.gz meson-b6723b3d7c57968fc4005f2143023c7e43753466.tar.bz2 |
wrap-mode: Make the error output more useful
Now it errors out while displaying the possible options
See: https://bugs.python.org/issue25061 for native support
-rw-r--r-- | mesonbuild/mesonmain.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index ab14b15..ec2bc58 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -63,6 +63,14 @@ add_builtin_argument('warnlevel', dest='warning_level') add_builtin_argument('stdsplit', action='store_false') add_builtin_argument('errorlogs', action='store_false') +def wrapmodetype(string): + try: + return getattr(WrapMode, string) + except AttributeError: + msg = ', '.join([t.name.lower() for t in WrapMode]) + msg = 'invalid argument {!r}, use one of {}'.format(string, msg) + raise argparse.ArgumentTypeError(msg) + parser.add_argument('--cross-file', default=None, help='File describing cross compilation environment.') parser.add_argument('-D', action='append', dest='projectoptions', default=[], metavar="option", @@ -71,7 +79,7 @@ parser.add_argument('-v', '--version', action='version', version=coredata.version) # See the mesonlib.WrapMode enum for documentation parser.add_argument('--wrap-mode', default=WrapMode.default, - type=lambda t: getattr(WrapMode, t), choices=WrapMode, + type=wrapmodetype, choices=WrapMode, help='Special wrap mode to use') parser.add_argument('directories', nargs='*') |