Check type of options passed to __init__
This commit is contained in:
parent
c74e3d68d6
commit
9b833db364
|
@ -111,10 +111,15 @@ class CliMenu:
|
||||||
|
|
||||||
if options:
|
if options:
|
||||||
for option in options:
|
for option in options:
|
||||||
if isinstance(option, tuple) and len(option) == 2:
|
if isinstance(option, tuple):
|
||||||
self.add_option(*option)
|
self.add_option(*option)
|
||||||
else:
|
elif isinstance(option, dict):
|
||||||
|
self.add_option(**option)
|
||||||
|
elif isinstance(option, str):
|
||||||
self.add_option(option, option)
|
self.add_option(option, option)
|
||||||
|
else:
|
||||||
|
raise ValueError("Option needs to be either tuple, dict or string, found '{}' of type {}"
|
||||||
|
.format(option, type(option)))
|
||||||
|
|
||||||
def add_header(self, *args, **kwargs):
|
def add_header(self, *args, **kwargs):
|
||||||
return self.add_text(*args, **kwargs)
|
return self.add_text(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue