forked from CITGuru/PyInquirer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.py
55 lines (46 loc) · 1.27 KB
/
list.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
list prompt example
"""
from __future__ import print_function, unicode_literals
from pprint import pprint
from PyInquirer import prompt, Separator
from examples import custom_style_2
def get_delivery_options(answers):
options = ['bike', 'car', 'truck']
if answers['size'] == 'jumbo':
options.append('helicopter')
return options
questions = [
{
'type': 'list',
'name': 'theme',
'message': 'What do you want to do?',
'choices': [
'Order a pizza',
'Make a reservation',
Separator(),
'Ask for opening hours',
{
'name': 'Contact support',
'disabled': 'Unavailable at this time'
},
'Talk to the receptionist'
]
},
{
'type': 'list',
'name': 'size',
'message': 'What size do you need?',
'choices': ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
'filter': lambda val: val.lower()
},
{
'type': 'list',
'name': 'delivery',
'message': 'Which vehicle you want to use for delivery?',
'choices': get_delivery_options,
},
]
answers = prompt.prompt(questions, style=custom_style_2)
pprint(answers)