Command I/O and Prompts

Command Input, Output, and Laravel Prompts

Questions come from Laravel Prompts 726 (laravel/prompts 0.3.24, bundled), whose text(), select(), multiselect(), search(), confirm() and spin() render validated, keyboard-driven forms. chooseTitles() returns every low title at once when $this->input->isInteractive() is false (--no-interaction, cron, CI); otherwise it asks:

The prompts inside chooseTitles()PHP
$skus = multiselect(
    label: 'Which titles should be restocked?',
    options: $low->mapWithKeys(fn ($p) => [$p->sku => "{$p->title} ({$p->stock})"]),
    default: $low->pluck('sku')->all(),
    required: 'Choose at least one title.',
    hint: 'Space toggles a title, Enter confirms.',
);
if (! confirm('Add ' . $amount . ' copies to each of ' . count($skus) . ' titles?')) {
    $this->fail('Cancelled; nothing was changed.');
}
return $low->whereIn('sku', $skus);

Driven through expect in a terminal, after Down and Space had cleared the second title (the table above it is omitted):

Output of 195
 ┌ Which titles should be restocked? ───────────────────────────┐
 │   ◼ MySQL Query Tuning (3)                                   │
 │ › ◻ Apache in Practice (0)                                   │
 │   ◼ Linux for Web Developers (4)                             │
 └──────────────────────────────────────────────────────────────┘
  Space toggles a title, Enter confirms.

Enter, then Yes, restocked the other two. PromptsForMissingInput prompts for missing required arguments, Isolatable adds --isolated (a cache lock against concurrent runs), and on Windows outside WSL 6 Prompts falls back to Symfony 6,093 's plain questions.