-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathselect_search.py
62 lines (52 loc) · 1.67 KB
/
select_search.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
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
"""Example for a select question type with search enabled.
Run example by typing `python -m examples.select_search` in your console."""
from pprint import pprint
import questionary
from examples import custom_style_dope
from questionary import Choice
from questionary import Separator
from questionary import prompt
def ask_pystyle(**kwargs):
# create the question object
question = questionary.select(
"What do you want to do?",
qmark="😃",
choices=[
"Order a pizza",
"Make a reservation",
"Cancel a reservation",
"Modify your order",
Separator(),
"Ask for opening hours",
Choice("Contact support", disabled="Unavailable at this time"),
"Talk to the receptionist",
],
style=custom_style_dope,
use_jk_keys=False,
use_search_filter=True,
**kwargs,
)
# prompt the user for an answer
return question.ask()
def ask_dictstyle(**kwargs):
questions = [
{
"type": "select",
"name": "theme",
"message": "What do you want to do?",
"choices": [
"Order a pizza",
"Make a reservation",
"Cancel a reservation",
"Modify your order",
Separator(),
"Ask for opening hours",
{"name": "Contact support", "disabled": "Unavailable at this time"},
"Talk to the receptionist",
],
}
]
return prompt(questions, style=custom_style_dope, **kwargs)
if __name__ == "__main__":
pprint(ask_pystyle())