0
# Advanced Prompts
1
2
Specialized prompts including fuzzy search, expandable choices, and numeric input with advanced features and customization options.
3
4
## Capabilities
5
6
### Fuzzy Search Prompt
7
8
Interactive fuzzy search prompt with real-time filtering and optional exact matching mode.
9
10
```python { .api }
11
def fuzzy(
12
message: InquirerPyMessage,
13
choices: InquirerPyListChoices,
14
default: InquirerPyDefault = "",
15
pointer: str = "❯",
16
qmark: str = "?",
17
amark: str = "?",
18
transformer: Optional[Callable[[Any], Any]] = None,
19
filter: Optional[Callable[[Any], Any]] = None,
20
instruction: str = "",
21
long_instruction: str = "",
22
multiselect: bool = False,
23
prompt: str = "❯",
24
border: bool = False,
25
info: bool = True,
26
match_exact: bool = False,
27
exact_symbol: str = " E",
28
height: Optional[Union[str, int]] = None,
29
max_height: Optional[Union[str, int]] = None,
30
validate: Optional[InquirerPyValidate] = None,
31
invalid_message: str = "Invalid input",
32
keybindings: Optional[InquirerPyKeybindings] = None,
33
cycle: bool = True,
34
wrap_lines: bool = True,
35
mandatory: bool = True,
36
mandatory_message: str = "Mandatory prompt",
37
style: Optional[InquirerPyStyle] = None,
38
vi_mode: bool = False,
39
raise_keyboard_interrupt: bool = True,
40
session_result: Optional[InquirerPySessionResult] = None,
41
**kwargs
42
) -> Any
43
```
44
45
**Parameters:**
46
- **choices**: List of searchable choices
47
- **prompt**: Symbol for search input field
48
- **info**: Show choice count information
49
- **match_exact**: Enable exact matching toggle (Ctrl+F)
50
- **exact_symbol**: Symbol displayed in exact match mode
51
- **multiselect**: Enable multi-selection mode
52
53
**Returns:** Selected choice or list of choices if multiselect=True
54
55
**Usage Examples:**
56
57
Basic fuzzy search:
58
```python
59
from InquirerPy import inquirer
60
61
# Large list with fuzzy search
62
framework = inquirer.fuzzy(
63
message="Search for framework:",
64
choices=[
65
"React", "Vue.js", "Angular", "Svelte", "Ember.js",
66
"Django", "Flask", "FastAPI", "Express.js", "Koa.js",
67
"Spring Boot", "Laravel", "Ruby on Rails", "ASP.NET"
68
],
69
default="React"
70
).execute()
71
```
72
73
Multi-select fuzzy search:
74
```python
75
# Multiple selection with fuzzy search
76
languages = inquirer.fuzzy(
77
message="Select programming languages:",
78
choices=[
79
"Python", "JavaScript", "TypeScript", "Java", "C#",
80
"Go", "Rust", "Swift", "Kotlin", "Dart", "Ruby", "PHP"
81
],
82
multiselect=True,
83
info=True
84
).execute()
85
```
86
87
With exact matching:
88
```python
89
# Enable exact match toggle
90
package = inquirer.fuzzy(
91
message="Search npm packages:",
92
choices=["react", "react-dom", "react-router", "react-query", "react-hook-form"],
93
match_exact=False,
94
exact_symbol=" [EXACT]",
95
instruction="Use Ctrl+F to toggle exact matching"
96
).execute()
97
```
98
99
### Expand Prompt
100
101
Compact prompt that expands to show choices, using single-character keys for selection.
102
103
```python { .api }
104
def expand(
105
message: InquirerPyMessage,
106
choices: InquirerPyListChoices,
107
default: InquirerPyDefault = "",
108
qmark: str = "?",
109
amark: str = "?",
110
pointer: str = " ",
111
separator: str = ") ",
112
help_msg: str = "Help, list all choices",
113
expand_help: Optional[ExpandHelp] = None,
114
expand_pointer: str = "❯ ",
115
instruction: str = "",
116
long_instruction: str = "",
117
transformer: Optional[Callable[[Any], Any]] = None,
118
filter: Optional[Callable[[Any], Any]] = None,
119
height: Optional[Union[int, str]] = None,
120
max_height: Optional[Union[int, str]] = None,
121
border: bool = False,
122
validate: Optional[InquirerPyValidate] = None,
123
invalid_message: str = "Invalid input",
124
keybindings: Optional[InquirerPyKeybindings] = None,
125
show_cursor: bool = True,
126
cycle: bool = True,
127
wrap_lines: bool = True,
128
mandatory: bool = True,
129
mandatory_message: str = "Mandatory prompt",
130
style: Optional[InquirerPyStyle] = None,
131
vi_mode: bool = False,
132
raise_keyboard_interrupt: bool = True,
133
session_result: Optional[InquirerPySessionResult] = None,
134
**kwargs
135
) -> Any
136
```
137
138
**Parameters:**
139
- **choices**: List of ExpandChoice objects or dictionaries with 'key' field
140
- **help_msg**: Help text for 'h' key option
141
- **expand_help**: Custom help configuration
142
- **expand_pointer**: Pointer symbol in expanded view
143
144
**Usage Examples:**
145
146
Basic expand prompt:
147
```python
148
from InquirerPy import inquirer
149
150
# Expand choices with key shortcuts
151
action = inquirer.expand(
152
message="Choose action:",
153
choices=[
154
{"key": "c", "name": "Create new file", "value": "create"},
155
{"key": "e", "name": "Edit existing file", "value": "edit"},
156
{"key": "d", "name": "Delete file", "value": "delete"},
157
{"key": "q", "name": "Quit", "value": "quit"}
158
],
159
default="create"
160
).execute()
161
```
162
163
With ExpandChoice objects:
164
```python
165
from InquirerPy.base.control import Choice
166
167
# Using ExpandChoice for more control
168
deployment = inquirer.expand(
169
message="Deployment target:",
170
choices=[
171
Choice("dev", key="d", name="Development server"),
172
Choice("staging", key="s", name="Staging environment"),
173
Choice("prod", key="p", name="Production server"),
174
Choice("local", key="l", name="Local environment")
175
],
176
help_msg="Show all deployment options"
177
).execute()
178
```
179
180
### Number Prompt
181
182
Numeric input prompt with validation, increment/decrement controls, and support for integers and floats.
183
184
```python { .api }
185
def number(
186
message: InquirerPyMessage,
187
default: InquirerPyDefault = 0,
188
float_allowed: bool = False,
189
max_allowed: Optional[Union[int, float]] = None,
190
min_allowed: Optional[Union[int, float]] = None,
191
decimal_symbol: str = ". ",
192
replace_mode: bool = False,
193
qmark: str = "?",
194
amark: str = "?",
195
instruction: str = "",
196
long_instruction: str = "",
197
validate: Optional[InquirerPyValidate] = None,
198
invalid_message: str = "Invalid input",
199
transformer: Optional[Callable[[str], Any]] = None,
200
filter: Optional[Callable[[str], Any]] = None,
201
keybindings: Optional[InquirerPyKeybindings] = None,
202
wrap_lines: bool = True,
203
mandatory: bool = True,
204
mandatory_message: str = "Mandatory prompt",
205
style: Optional[InquirerPyStyle] = None,
206
vi_mode: bool = False,
207
raise_keyboard_interrupt: bool = True,
208
session_result: Optional[InquirerPySessionResult] = None,
209
**kwargs
210
) -> Union[int, float]
211
```
212
213
**Parameters:**
214
- **float_allowed**: Allow decimal numbers
215
- **max_allowed/min_allowed**: Number range constraints
216
- **decimal_symbol**: Symbol for decimal separation
217
- **replace_mode**: Replace default on first key press
218
219
**Returns:** Integer or float based on float_allowed setting
220
221
**Usage Examples:**
222
223
Basic integer input:
224
```python
225
from InquirerPy import inquirer
226
227
# Simple integer input
228
port = inquirer.number(
229
message="Enter port number:",
230
default=8080,
231
min_allowed=1,
232
max_allowed=65535
233
).execute()
234
```
235
236
Float input with validation:
237
```python
238
# Decimal number with custom validation
239
price = inquirer.number(
240
message="Enter price:",
241
default=0.0,
242
float_allowed=True,
243
min_allowed=0.0,
244
decimal_symbol=" → ",
245
validate=lambda x: x > 0,
246
invalid_message="Price must be greater than 0"
247
).execute()
248
```
249
250
With increment/decrement:
251
```python
252
# Number with arrow key controls
253
threads = inquirer.number(
254
message="Number of threads:",
255
default=4,
256
min_allowed=1,
257
max_allowed=16,
258
instruction="Use ↑/↓ to adjust, Enter to confirm"
259
).execute()
260
```
261
262
## Class-based Usage
263
264
Direct class instantiation for advanced customization:
265
266
```python
267
from InquirerPy.prompts import FuzzyPrompt, ExpandPrompt, NumberPrompt
268
269
# FuzzyPrompt class
270
fuzzy_prompt = FuzzyPrompt(
271
message="Search:",
272
choices=["apple", "banana", "cherry", "date"],
273
match_exact=False,
274
multiselect=True
275
)
276
results = fuzzy_prompt.execute()
277
278
# ExpandPrompt class
279
expand_prompt = ExpandPrompt(
280
message="Action:",
281
choices=[
282
{"key": "s", "name": "Save", "value": "save"},
283
{"key": "q", "name": "Quit", "value": "quit"}
284
]
285
)
286
action = expand_prompt.execute()
287
288
# NumberPrompt class
289
number_prompt = NumberPrompt(
290
message="Count:",
291
default=10,
292
min_allowed=1,
293
max_allowed=100,
294
float_allowed=False
295
)
296
count = number_prompt.execute()
297
```
298
299
## Keyboard Controls
300
301
### Fuzzy Search
302
- **Type**: Filter choices in real-time
303
- **Ctrl+F**: Toggle exact matching mode
304
- **Space/Enter**: Select choice (or toggle if multiselect)
305
- **Tab**: Complete partial matches
306
- **Ctrl+A**: Select all (multiselect mode)
307
308
### Expand Prompt
309
- **Letter Keys**: Quick selection by assigned key
310
- **h**: Show help and expand all choices
311
- **Enter**: Confirm current selection
312
- **Up/Down**: Navigate in expanded mode
313
314
### Number Prompt
315
- **Up/Down Arrows**: Increment/decrement value
316
- **Number Keys**: Direct numeric input
317
- **Decimal Point**: Add decimal (if float_allowed)
318
- **Backspace**: Delete digits
319
- **Enter**: Confirm value