Interactive prompts — text, confirm, select, multi-select, textarea
Text, Confirm, Selection, MultiSelect, and Textarea prompts with full keyboard handling, filter-as-you-type, and pagination. State-machine model — no external readline dependency.
composer require sugarcraft/sugar-readline
use SugarCraft\Readline\{TextPrompt, SelectionPrompt, MultiSelectPrompt};
// Text prompt
$name = TextPrompt::new('Your name:')->HandleChar('A')->Confirm()->Value();
// Selection prompt
$lang = SelectionPrompt::new('Pick a language:', ['PHP', 'Go', 'Rust', 'Python'])
->HandleKey('enter');
// Multi-select with constraints
$tools = MultiSelectPrompt::new('Pick tools:', ['vim', 'git', 'docker', 'php'])
->WithMinSelections(1)
->WithMaxSelections(3)
->HandleKey('space')
->HandleKey('enter');
| Class | Method | Description |
|---|---|---|
| TextPrompt | new(question) | Create text prompt |
| TextPrompt | confirm() | Confirm input |
| ConfirmationPrompt | new(question) | Create yes/no prompt |
| SelectionPrompt | new(question, options) | Create selection prompt |
| MultiSelectPrompt | new(question, options) | Create multi-select prompt |
| MultiSelectPrompt | withMinSelections(n) | Set minimum selections |
| MultiSelectPrompt | withMaxSelections(n) | Set maximum selections |
| TextareaPrompt | new(question) | Create textarea prompt |
VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.