Python port of Inquirer.js providing interactive command-line user interfaces with extensive customization options.
—
Single and multi-selection list prompts with navigation, customizable display options, and support for complex choice structures.
Single-selection list prompt with keyboard navigation and customizable display options.
def select(
message: InquirerPyMessage,
choices: InquirerPyListChoices,
default: InquirerPyDefault = None,
qmark: str = "?",
amark: str = "?",
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 selection:
from InquirerPy import inquirer
# Simple choice selection
framework = inquirer.select(
message="Choose web framework:",
choices=["Flask", "Django", "FastAPI", "Tornado"],
default="FastAPI"
).execute()Complex choices with values:
# Choices with display names and actual values
database = inquirer.select(
message="Select database:",
choices=[
{"name": "PostgreSQL (Recommended)", "value": "postgresql"},
{"name": "MySQL", "value": "mysql"},
{"name": "SQLite", "value": "sqlite"},
{"name": "MongoDB", "value": "mongodb"}
]
).execute()With separators and height control:
from InquirerPy import inquirer
from InquirerPy.separator import Separator
environment = inquirer.select(
message="Choose deployment environment:",
choices=[
"development",
"testing",
Separator("--- Production ---"),
"staging",
"production",
Separator("--- Cloud ---"),
"aws",
"gcp",
"azure"
],
height="50%",
border=True
).execute()Multi-selection prompt allowing users to select multiple options with checkboxes.
def checkbox(
message: InquirerPyMessage,
choices: InquirerPyListChoices,
default: Any = None,
qmark: str = "?",
amark: str = "?",
pointer: str = "❯",
enabled_symbol: str = "●",
disabled_symbol: str = "○",
border: bool = False,
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,
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
) -> List[Any]Parameters:
Returns: List of selected values (empty list if none selected)
Usage Examples:
Basic multi-selection:
# Multiple technology selection
technologies = inquirer.checkbox(
message="Select technologies:",
choices=["Python", "JavaScript", "Java", "Go", "Rust", "C++"],
default=["Python", "JavaScript"]
).execute()With validation:
# Require at least one selection
features = inquirer.checkbox(
message="Select features to enable:",
choices=["Authentication", "Database", "Caching", "Logging", "Monitoring"],
validate=lambda result: len(result) >= 1,
invalid_message="Please select at least one feature"
).execute()Numbered list selection limited to 9 choices with keyboard shortcuts.
def rawlist(
message: InquirerPyMessage,
choices: InquirerPyListChoices,
default: InquirerPyDefault = None,
separator: str = ") ",
qmark: str = "?",
amark: str = "?",
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 Example:
# Quick numbered selection
priority = inquirer.rawlist(
message="Select priority level:",
choices=["Low", "Medium", "High", "Critical"],
default="Medium"
).execute()
# Displays as: 1) Low 2) Medium 3) High 4) CriticalChoices can be strings, dictionaries, or Choice objects:
# String choices (simple)
choices = ["Option 1", "Option 2", "Option 3"]
# Dictionary choices (name/value pairs)
choices = [
{"name": "Development Server", "value": "dev"},
{"name": "Production Server", "value": "prod"}
]
# Choice objects with additional properties
from InquirerPy.base.control import Choice
choices = [
Choice("item1", name="First Item", enabled=True),
Choice("item2", name="Second Item", enabled=False),
Choice("item3", name="Third Item")
]Choices can be generated dynamically based on previous answers:
from InquirerPy import prompt
questions = [
{
"type": "select",
"message": "Choose category:",
"choices": ["Frontend", "Backend", "DevOps"],
"name": "category"
},
{
"type": "checkbox",
"message": "Select tools:",
"choices": lambda answers: {
"Frontend": ["React", "Vue", "Angular"],
"Backend": ["Django", "Flask", "FastAPI"],
"DevOps": ["Docker", "Kubernetes", "Terraform"]
}.get(answers["category"], []),
"name": "tools"
}
]
result = prompt(questions)from InquirerPy.prompts import ListPrompt, CheckboxPrompt, RawlistPrompt
# ListPrompt class
list_prompt = ListPrompt(
message="Choose option:",
choices=["A", "B", "C"],
height=10,
border=True
)
selection = list_prompt.execute()
# CheckboxPrompt class
checkbox_prompt = CheckboxPrompt(
message="Select multiple:",
choices=["X", "Y", "Z"],
default=["X"]
)
selections = checkbox_prompt.execute()
# RawlistPrompt class
rawlist_prompt = RawlistPrompt(
message="Pick one:",
choices=["First", "Second", "Third"],
separator=" -> "
)
pick = rawlist_prompt.execute()Install with Tessl CLI
npx tessl i tessl/pypi-inquirerpy