Feature request: section support
henzeb opened this issue · 3 comments
I would love to see some support on sections.
Symfony has implementation for that, but was never really used in Laravel.
What it does is creating a segment in which you can add or delete lines while also having other segments which can be edited independently from each other.
One of the ideas is to be able to clear out prompts when entered information, but we can do so many things with sections. We could do live updating of sections using Laravel Reverb ;-)
An example of what could be done:
section('foo', function(){
// anything in here happens within the section
info('hello');
// .... creating progressbars, requesting information.
})->clear();
info('we are done');
Another example:
info('asking questions:', section: 'foo');
$bar = section('bar');
$name = text('your name?', section: 'bar');
$bar->clear();
$password = password('your password?', section: $bar);
$bar->replace(
function(){
// replaces the entire content. Imagine it does more output.
info('Thanks!');
}
)
info('done asking questions.', section: 'foo');
After tinkering with Prompts a bit, I don't think sections are really needed for the watch method after all, They can be separated Feature Requests. I will PR the watch prompt somewhere this weekend.
Thanks! Let's see how your PR goes.
apparently it is not wanted. Made a package for it. https://packagist.org/packages/henzeb/prompts-extras