Prompts & Input
Bunli provides a comprehensive prompt API through@bunli/runtime/prompt for collecting user input in interactive terminals.
Prompt API
Text Input
Collect text input from the user:With Validation
With Schema Validation
Password Input
Collect sensitive input without echoing to the terminal:- Hidden by default - Characters not displayed
- Reveal toggle - Press
Ctrl+Rto toggle visibility - Automatic terminal echo management
Confirmation
Get yes/no confirmation from the user:Select (Single Choice)
Present a list of options for single selection:Disabled Options
↑/↓ork/j- Move selection1-9- Quick select by numberEnter- Confirm selectionEsc- Cancel
Multi-Select
Allow multiple selections:↑/↓ork/j- Move cursorSpace- Toggle selection1-9- Quick toggle by numberEnter- Submit selectionsEsc- Cancel
Prompt Helpers
Intro / Outro
Add decorative headers and footers:Notes
Display formatted information:Logging
Structured log output:Spinners
Basic Spinner
Show progress for long-running operations:Spinner API
Spinner Options
Multiple Steps
Cancellation Handling
All prompts can be cancelled withEsc or Ctrl+C:
Sequential Prompts
Group related prompts:Non-Interactive Mode
Provide fallback values for non-interactive environments (CI/CD):Prompt Session
Create isolated prompt sessions for better control:OpenTUI Integration
Prompts use OpenTUI under the hood for rich rendering:Real-World Example
Next Steps
Rendering
Learn about the renderer API
Components
Explore UI components for complex forms