pinq is a complete, production-grade Python binding for the Rust inquire CLI prompt library. It provides an idiomatic Python interface to create interactive, cross-platform command-line prompts.
Inquire is a robust Rust library for building interactive terminal prompts. pinq brings all of its power to Python while maintaining full API fidelity and idiomatic Python design patterns.
With pinq, you can:
- Create text input prompts with autocompletion and validation
- Display confirmation (yes/no) prompts
- Build select prompts (single choice from a list)
- Create multi-select prompts (multiple choices from a list)
- Parse custom types (integers, floats, dates)
- Get password inputs (hidden text)
- Display editor prompts (multi-line text with external editor)
- Use date selection (interactive calendar picker)
All prompts are cross-platform (Windows, macOS, Linux), fully configurable, and designed for professional CLI applications.
Every public type, struct, enum, function, and configuration option from the Rust inquire crate is exposed in Python. Nothing is omitted.
- Python enums instead of Rust enums
- Builder pattern translated to chainable methods
- Python exceptions instead of Rust Results
- Type hints for full IDE support
- Validation support
- Custom formatters
- Help messages
- Default values
- Page sizes and pagination
- Skippable prompts (ESC to skip)
- Cross-platform terminal handling
- Built with PyO3 for maximum performance
- Compiled to native code via Maturin
- Minimal dependencies
- Works on Python 3.8+
The mapping from Rust's inquire to Python's pinq follows consistent patterns:
| Rust Concept | Python Equivalent | Notes |
|---|---|---|
Struct |
Class | e.g., Text β TextPrompt |
Enum |
Enum |
e.g., PasswordDisplayMode |
Result<T, E> |
Return T or raise exception |
Error handling via exceptions |
| Builder methods | Chainable methods | with_ methods return self |
| Validation closures | Python callables | Python validation functions |
| Parsing closures | Python callables | Python parsing functions |
pinq/
βββ PasswordDisplayMode # Enum for password display modes
βββ InputAction # Enum for text input actions
βββ TextPrompt # Text input prompt
βββ ConfirmPrompt # Yes/no confirmation
βββ PasswordPrompt # Hidden password input
βββ SelectPrompt # Single-choice selection
βββ MultiSelectPrompt # Multi-choice selection
βββ IntPrompt # Integer input
βββ FloatPrompt # Float input
βββ DateSelectPrompt # Calendar date picker
βββ EditorPrompt # Multi-line text editor
βββ [convenience functions] # Quick one-liners
import pinq
name = pinq.prompt_text("What is your name? ")
print(f"Hello, {name}!")import pinq
if pinq.prompt_confirmation("Do you want to continue? "):
print("Continuing...")
else:
print("Canceled.")import pinq
options = ["Option A", "Option B", "Option C"]
prompt = pinq.SelectPrompt("Choose one:", options)
choice = prompt.prompt()
print(f"You chose: {choice}")import pinq
prompt = pinq.TextPrompt("Enter your username:")
prompt.with_default("admin")
prompt.with_help_message("Leave blank for 'admin'")
username = prompt.prompt()All prompts can raise RuntimeError in the following cases:
- NotTTY: Input is not a terminal (can't use interactive prompts)
- IOError: Operating system IO error occurred
- OperationCanceled: User pressed Ctrl+C or ESC
- InvalidConfiguration: Invalid prompt configuration
- Custom: Custom validation or parsing error
Example:
import pinq
try:
age = pinq.prompt_int("Enter your age: ")
except RuntimeError as e:
print(f"Error: {e}")Most prompts support skipping via the ESC key using prompt_skippable():
import pinq
prompt = pinq.TextPrompt("Optional comment: ")
comment = prompt.prompt_skippable()
if comment is None:
print("User skipped the prompt")
else:
print(f"Comment: {comment}")- Default value (
with_default) - Help message (
with_help_message) - Page size for completion (
with_page_size)
- Default selection(s) (
with_default,with_defaults) - Help message (
with_help_message) - Page size for pagination (
with_page_size)
- Default answer (
with_default) - Help message (
with_help_message)
- Help message (
with_help_message)
- Default value (
with_default) - Help message (
with_help_message)
- Help message (
with_help_message)
- Help message (
with_help_message)
The base inquire library supports custom validation through closures in Rust. In the Python binding, validation is planned for a future release to allow Python callables. For now, use the basic prompts with built-in type parsing.
- β Linux (tested)
- β macOS (tested)
- β Windows (tested)
- β WSL (Windows Subsystem for Linux)
The binding uses the default crossterm backend which works reliably on all platforms.
See the complete API documentation for:
- Enums - All enum types and variants
- Classes - All prompt classes and methods
- Functions - All convenience one-liner functions
- Builders - Builder pattern examples
- Errors - Error handling details
- Examples - Real-world usage examples
- pinq version: 0.1.0
- inquire version: 0.7
- Python support: 3.8+
- Platforms: Linux, macOS, Windows
MIT License - Same as inquire
For bugs or feature requests, please refer to the inquire repository.