-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppTypeSelector.py
36 lines (30 loc) · 1.05 KB
/
AppTypeSelector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import inquirer
class AppTypeSelector:
def __init__(self, types):
self.types = []
for typ in types:
key, value = list(typ.items())[0]
self.types.append((value, key))
def select_types(self, select_one=False):
if select_one:
questions = [
inquirer.List(
"type",
message="Select a type to run",
choices=self.types,
),
]
else:
questions = [
inquirer.Checkbox(
"types",
message="Select types to run",
choices=self.types,
),
]
answers = inquirer.prompt(questions)
if select_one:
selected_type = [(value, key) for value, key in self.types if key == answers['type']]
return selected_type[0] if selected_type else None
selected_types = [(value, key) for value, key in self.types if key in answers['types']]
return selected_types