Browse Source

Check type of options passed to __init__

Sebastian Lohff 1 year ago
parent
commit
9b833db364
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      clintermission/climenu.py

+ 7
- 2
clintermission/climenu.py View File

@@ -111,10 +111,15 @@ class CliMenu:
111 111
 
112 112
         if options:
113 113
             for option in options:
114
-                if isinstance(option, tuple) and len(option) == 2:
114
+                if isinstance(option, tuple):
115 115
                     self.add_option(*option)
116
-                else:
116
+                elif isinstance(option, dict):
117
+                    self.add_option(**option)
118
+                elif isinstance(option, str):
117 119
                     self.add_option(option, option)
120
+                else:
121
+                    raise ValueError("Option needs to be either tuple, dict or string, found '{}' of type {}"
122
+                                     .format(option, type(option)))
118 123
 
119 124
     def add_header(self, *args, **kwargs):
120 125
         return self.add_text(*args, **kwargs)

Loading…
Cancel
Save