Python port of Inquirer.js providing interactive command-line user interfaces with extensive customization options.
—
Specialized prompts including fuzzy search, expandable choices, and numeric input with advanced features and customization options.
Interactive fuzzy search prompt with real-time filtering and optional exact matching mode.
def fuzzy(
message: InquirerPyMessage,
choices: InquirerPyListChoices,
default: InquirerPyDefault = "",
pointer: str = "❯",
qmark: str = "?",
amark: str = "?",
transformer: Optional[Callable[[Any], Any]] = None,
filter: Optional[Callable[[Any], Any]] = None,
instruction: str = "",
long_instruction: str = "",
multiselect: bool = False,
prompt: str = "❯",
border: bool = False,
info: bool = True,
match_exact: bool = False,
exact_symbol: str = " E",
height: Optional[Union[str, int]] = None,
max_height: Optional[Union[str, int]] = None,
validate: Optional[InquirerPyValidate] = None,
invalid_message: str = "Invalid input",
keybindings: Optional[InquirerPyKeybindings] = None,
cycle: bool = True,
wrap_lines: bool = True,
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
style: Optional[InquirerPyStyle] = None,
vi_mode: bool = False,
raise_keyboard_interrupt: bool = True,
session_result: Optional[InquirerPySessionResult] = None,
**kwargs
) -> AnyParameters:
Returns: Selected choice or list of choices if multiselect=True
Usage Examples:
Basic fuzzy search:
from InquirerPy import inquirer
# Large list with fuzzy search
framework = inquirer.fuzzy(
message="Search for framework:",
choices=[
"React", "Vue.js", "Angular", "Svelte", "Ember.js",
"Django", "Flask", "FastAPI", "Express.js", "Koa.js",
"Spring Boot", "Laravel", "Ruby on Rails", "ASP.NET"
],
default="React"
).execute()Multi-select fuzzy search:
# Multiple selection with fuzzy search
languages = inquirer.fuzzy(
message="Select programming languages:",
choices=[
"Python", "JavaScript", "TypeScript", "Java", "C#",
"Go", "Rust", "Swift", "Kotlin", "Dart", "Ruby", "PHP"
],
multiselect=True,
info=True
).execute()With exact matching:
# Enable exact match toggle
package = inquirer.fuzzy(
message="Search npm packages:",
choices=["react", "react-dom", "react-router", "react-query", "react-hook-form"],
match_exact=False,
exact_symbol=" [EXACT]",
instruction="Use Ctrl+F to toggle exact matching"
).execute()Compact prompt that expands to show choices, using single-character keys for selection.
def expand(
message: InquirerPyMessage,
choices: InquirerPyListChoices,
default: InquirerPyDefault = "",
qmark: str = "?",
amark: str = "?",
pointer: str = " ",
separator: str = ") ",
help_msg: str = "Help, list all choices",
expand_help: Optional[ExpandHelp] = None,
expand_pointer: str = "❯ ",
instruction: str = "",
long_instruction: str = "",
transformer: Optional[Callable[[Any], Any]] = None,
filter: Optional[Callable[[Any], Any]] = None,
height: Optional[Union[int, str]] = None,
max_height: Optional[Union[int, str]] = None,
border: bool = False,
validate: Optional[InquirerPyValidate] = None,
invalid_message: str = "Invalid input",
keybindings: Optional[InquirerPyKeybindings] = None,
show_cursor: bool = True,
cycle: bool = True,
wrap_lines: bool = True,
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
style: Optional[InquirerPyStyle] = None,
vi_mode: bool = False,
raise_keyboard_interrupt: bool = True,
session_result: Optional[InquirerPySessionResult] = None,
**kwargs
) -> AnyParameters:
Usage Examples:
Basic expand prompt:
from InquirerPy import inquirer
# Expand choices with key shortcuts
action = inquirer.expand(
message="Choose action:",
choices=[
{"key": "c", "name": "Create new file", "value": "create"},
{"key": "e", "name": "Edit existing file", "value": "edit"},
{"key": "d", "name": "Delete file", "value": "delete"},
{"key": "q", "name": "Quit", "value": "quit"}
],
default="create"
).execute()With ExpandChoice objects:
from InquirerPy.base.control import Choice
# Using ExpandChoice for more control
deployment = inquirer.expand(
message="Deployment target:",
choices=[
Choice("dev", key="d", name="Development server"),
Choice("staging", key="s", name="Staging environment"),
Choice("prod", key="p", name="Production server"),
Choice("local", key="l", name="Local environment")
],
help_msg="Show all deployment options"
).execute()Numeric input prompt with validation, increment/decrement controls, and support for integers and floats.
def number(
message: InquirerPyMessage,
default: InquirerPyDefault = 0,
float_allowed: bool = False,
max_allowed: Optional[Union[int, float]] = None,
min_allowed: Optional[Union[int, float]] = None,
decimal_symbol: str = ". ",
replace_mode: bool = False,
qmark: str = "?",
amark: str = "?",
instruction: str = "",
long_instruction: str = "",
validate: Optional[InquirerPyValidate] = None,
invalid_message: str = "Invalid input",
transformer: Optional[Callable[[str], Any]] = None,
filter: Optional[Callable[[str], Any]] = None,
keybindings: Optional[InquirerPyKeybindings] = None,
wrap_lines: bool = True,
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
style: Optional[InquirerPyStyle] = None,
vi_mode: bool = False,
raise_keyboard_interrupt: bool = True,
session_result: Optional[InquirerPySessionResult] = None,
**kwargs
) -> Union[int, float]Parameters:
Returns: Integer or float based on float_allowed setting
Usage Examples:
Basic integer input:
from InquirerPy import inquirer
# Simple integer input
port = inquirer.number(
message="Enter port number:",
default=8080,
min_allowed=1,
max_allowed=65535
).execute()Float input with validation:
# Decimal number with custom validation
price = inquirer.number(
message="Enter price:",
default=0.0,
float_allowed=True,
min_allowed=0.0,
decimal_symbol=" → ",
validate=lambda x: x > 0,
invalid_message="Price must be greater than 0"
).execute()With increment/decrement:
# Number with arrow key controls
threads = inquirer.number(
message="Number of threads:",
default=4,
min_allowed=1,
max_allowed=16,
instruction="Use ↑/↓ to adjust, Enter to confirm"
).execute()Direct class instantiation for advanced customization:
from InquirerPy.prompts import FuzzyPrompt, ExpandPrompt, NumberPrompt
# FuzzyPrompt class
fuzzy_prompt = FuzzyPrompt(
message="Search:",
choices=["apple", "banana", "cherry", "date"],
match_exact=False,
multiselect=True
)
results = fuzzy_prompt.execute()
# ExpandPrompt class
expand_prompt = ExpandPrompt(
message="Action:",
choices=[
{"key": "s", "name": "Save", "value": "save"},
{"key": "q", "name": "Quit", "value": "quit"}
]
)
action = expand_prompt.execute()
# NumberPrompt class
number_prompt = NumberPrompt(
message="Count:",
default=10,
min_allowed=1,
max_allowed=100,
float_allowed=False
)
count = number_prompt.execute()Install with Tessl CLI
npx tessl i tessl/pypi-inquirerpy