-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_tour.py
More file actions
72 lines (62 loc) · 1.79 KB
/
quick_tour.py
File metadata and controls
72 lines (62 loc) · 1.79 KB
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
63
64
65
66
67
68
69
70
71
72
"""Quick Tour - Overview of all python-clack prompts."""
from python_clack import (
cancel,
confirm,
intro,
is_cancel,
log,
multiselect,
outro,
password,
select,
text,
)
def run() -> None:
"""Run the quick tour demo."""
intro("Quick Tour - All Prompts Overview")
# text() - basic input
name = text("What's your name?", placeholder="Enter your name")
if is_cancel(name):
cancel()
return
# select() - single choice with hints
theme = select(
"Pick a theme",
options=[
{"value": "light", "label": "Light", "hint": "bright colors"},
{"value": "dark", "label": "Dark", "hint": "easy on eyes"},
{"value": "system", "label": "System", "hint": "match OS"},
],
)
if is_cancel(theme):
cancel()
return
# multiselect() - multiple choices
interests: list[str] = multiselect( # type: ignore[assignment]
"Select your interests",
options=[
{"value": "cli", "label": "CLI tools"},
{"value": "web", "label": "Web development"},
{"value": "data", "label": "Data science"},
{"value": "devops", "label": "DevOps"},
],
required=True,
)
if is_cancel(interests):
cancel()
return
# password() - masked input
token = password("API token (optional)")
if is_cancel(token):
cancel()
return
# confirm() - yes/no
proceed = confirm(f"All set, {name}?", initial_value=True)
if is_cancel(proceed) or not proceed:
cancel("Tour cancelled")
return
# Summary with logging
log.success(f"Welcome, {name}!")
log.info(f"Theme: {theme}")
log.step(f"Interests: {', '.join(interests)}")
outro("Tour complete!")