InquirerPy
InquirerPy is a Python port of the famous Inquirer.js, offering a collection of common interactive command-line user interfaces. It is a re-implementation of the PyInquirer project, focusing on bug fixes, new prompts, backward-compatible APIs, and enhanced customization. Currently at version 0.3.4, the library maintains an active development and release cadence.
Warnings
- breaking When migrating from PyInquirer, note that 'EditorPrompt' is not supported in InquirerPy. Also, parameters for 'CheckboxPrompt' (e.g., `pointer_sign` changed to `pointer`) and keys for 'Style' (e.g., `selected` changed to `pointer`) have been renamed or altered.
- deprecated The `raise_keyboard_interrupt` parameter in the `.execute()` function is slated for deprecation. Its behavior has changed, and the recommended approach is to provide `raise_keyboard_interrupt` as an initialisation option to the prompt class.
- gotcha In version 0.3.4, automatic spacing was introduced for checkbox, expand, and rawlist prompts. If you have custom `enabled_symbol` or `disabled_symbol` configurations, you might need to remove any extra spaces you previously added to maintain alignment.
- deprecated For the `expand` prompt, the `help_msg` parameter has been deprecated in favor of `expand_help` for customising help messages and expansion keys.
- gotcha The default value for the `border` parameter in fuzzy prompts was changed from `True` to `False` in version 0.3.4 to ensure consistency with other prompt types.
Install
-
pip install InquirerPy
Imports
- inquirer
from InquirerPy import inquirer
- prompt
from InquirerPy import prompt
- Validator
from InquirerPy.validator import Validator
Quickstart
from InquirerPy import inquirer
name = inquirer.text(message="What's your name:").execute()
fav_lang = inquirer.select(
message="What's your favourite programming language:",
choices=["Go", "Python", "Rust", "JavaScript"],
).execute()
confirm = inquirer.confirm(message="Confirm?").execute()
print(f"Hello {name}, your favourite language is {fav_lang}, and you confirmed: {confirm}")