aboutsummaryrefslogtreecommitdiff
path: root/optinterpreter.py
diff options
context:
space:
mode:
Diffstat (limited to 'optinterpreter.py')
-rw-r--r--optinterpreter.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/optinterpreter.py b/optinterpreter.py
index e2f72d0..9d23536 100644
--- a/optinterpreter.py
+++ b/optinterpreter.py
@@ -38,8 +38,24 @@ class UserBooleanOption(UserOption):
if not isinstance(self.value, bool):
raise OptionException('Value of boolean option is not boolean.')
+class UserComboOption(UserOption):
+ def __init__(self, kwargs):
+ super().__init__(kwargs)
+ if 'choices' not in kwargs:
+ raise OptionException('Combo option missing "choices" keyword.')
+ self.choices = kwargs['choices']
+ if not isinstance(self.choices, list):
+ raise OptionException('Combo choices must be an array.')
+ for i in self.choices:
+ if not isinstance(i, str):
+ raise OptionException('Combo choice elements must be strings.')
+ self.value = kwargs.get('value', self.choices[0])
+ if self.value not in self.choices:
+ raise OptionException('Combo value must be one of the choices.')
+
option_types = {'string' : UserStringOption,
'boolean' : UserBooleanOption,
+ 'combo' : UserComboOption,
}
class OptionInterpreter: