Python port of Inquirer.js providing interactive command-line user interfaces with extensive customization options.
npx @tessl/cli install tessl/pypi-inquirerpy@0.3.0A comprehensive Python library that provides interactive command-line user interfaces, serving as a modern port of the popular Inquirer.js library. InquirerPy offers a rich collection of customizable prompts built on top of prompt-toolkit, providing cross-platform compatibility with extensive customization options for styling, key bindings, and modern Python type hinting.
pip install InquirerPyClassic syntax (PyInquirer compatible):
from InquirerPy import promptAlternate syntax with type hints:
from InquirerPy import inquirerIndividual prompt classes:
from InquirerPy.prompts import InputPrompt, ConfirmPrompt, ListPromptfrom InquirerPy import prompt
questions = [
{"type": "input", "message": "What's your name:", "name": "name"},
{"type": "confirm", "message": "Confirm?", "name": "confirm", "default": True},
{"type": "list", "message": "Choose option:", "choices": ["Option 1", "Option 2"], "name": "choice"}
]
result = prompt(questions)
print(f"Hello {result['name']}, you chose {result['choice']}")from InquirerPy import inquirer
name = inquirer.text(message="What's your name:").execute()
confirm = inquirer.confirm(message="Confirm?", default=True).execute()
choice = inquirer.select(message="Choose option:", choices=["Option 1", "Option 2"]).execute()
print(f"Hello {name}, you chose {choice}")InquirerPy is built on a hierarchical architecture:
prompt() function and alternate inquirer moduleBasic text input, password/secret input, and file path selection with auto-completion and validation support.
def text(message, default="", validate=None, **kwargs): ...
def secret(message, default="", validate=None, **kwargs): ...
def filepath(message, default="", only_files=False, only_directories=False, **kwargs): ...Yes/no confirmation prompts with customizable confirm/reject letters and single keypress operation.
def confirm(message, default=False, confirm_letter="y", reject_letter="n", **kwargs): ...Single and multi-selection list prompts with navigation, searching, and customizable display options.
def select(message, choices, default=None, **kwargs): ...
def checkbox(message, choices, default=None, **kwargs): ...
def rawlist(message, choices, default=None, separator=") ", **kwargs): ...Specialized prompts including fuzzy search, expandable choices, and numeric input with validation.
def fuzzy(message, choices, default="", match_exact=False, **kwargs): ...
def expand(message, choices, default="", help_msg="Help, list all choices", **kwargs): ...
def number(message, default=0, float_allowed=False, min_allowed=None, max_allowed=None, **kwargs): ...PyInquirer-compatible prompt functions supporting question dictionaries and async operations.
def prompt(questions, style=None, vi_mode=False, keybindings=None, **kwargs): ...
def prompt_async(questions, style=None, vi_mode=False, keybindings=None, **kwargs): ...Styling, validation, separators, and utility functions for prompt customization and enhanced functionality.
def get_style(style=None, style_override=True): ...
class Separator(line="---------------"): ...
class NumberValidator(message="Input should be a number", float_allowed=False): ...# Session result type
InquirerPySessionResult = Dict[Union[str, int], Optional[Union[str, bool, List[Any]]]]
# Type aliases for flexible parameter types
InquirerPyMessage = Union[str, Callable[[InquirerPySessionResult], str]]
InquirerPyDefault = Union[Any, Callable[[InquirerPySessionResult], Any]]
InquirerPyChoice = Union[List[Any], List["Choice"], List[Dict[str, Any]]]
InquirerPyListChoices = Union[
Callable[[InquirerPySessionResult], InquirerPyChoice],
InquirerPyChoice
]
InquirerPyValidate = Union[Callable[[Any], bool], "Validator"]
InquirerPyKeybindings = Dict[str, List[Dict[str, Union[str, "FilterOrBool", List[str]]]]]
InquirerPyQuestions = Union[List[Dict[str, Any]], Dict[str, Any]]
# Style configuration
class InquirerPyStyle(NamedTuple):
dict: Dict[str, str]
# Choice classes for prompts
@dataclass
class Choice:
value: Any
name: Optional[str] = None
enabled: bool = False
@dataclass
class ExpandChoice(Choice):
key: Optional[str] = None
@dataclass
class ExpandHelp:
key: str = "h"
message: str = "Help, list all choices"