diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-11-27 22:16:32 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-12-02 20:34:45 +0200 |
commit | dae21b70db07ca4d1a65c34fac6ec090761ac45f (patch) | |
tree | af5713459e1f9413ab07cb1cd3ec5b8c6ee72d29 /mesonbuild/optinterpreter.py | |
parent | aa6b5762564af7fc2a01791183db684872311f48 (diff) | |
download | meson-arrayopt.tar.gz |
String arguments can permit arbitrary string valuesarrayopt
by leaving out the choices keyword.
Diffstat (limited to 'mesonbuild/optinterpreter.py')
-rw-r--r-- | mesonbuild/optinterpreter.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 22a263e72..3cca2394f 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -86,15 +86,17 @@ def ComboParser(name, description, kwargs): @permitted_kwargs({'value', 'choices'}) def string_array_parser(name, description, kwargs): - if 'choices' not in kwargs: - raise OptionException('Array option missing "choices" keyword.') - choices = kwargs['choices'] - if not isinstance(choices, list): - raise OptionException('Array choices must be an array.') - for i in choices: - if not isinstance(i, str): - raise OptionException('Array choice elements must be strings.') - value = kwargs.get('value', choices) + if 'choices' in kwargs: + choices = kwargs['choices'] + if not isinstance(choices, list): + raise OptionException('Array choices must be an array.') + for i in choices: + if not isinstance(i, str): + raise OptionException('Array choice elements must be strings.') + value = kwargs.get('value', choices) + else: + choices = None + value = kwargs.get('value', []) if not isinstance(value, list): raise OptionException('Array choices must be passed as an array.') return coredata.UserStringArrayOption(name, description, value, choices=choices) |