nunomaduro / termwind

🍃 In short, it's like Tailwind CSS, but for the PHP command-line applications.
MIT License
2.27k stars 76 forks source link

Is there a way to have a default answer for the ask() methods? #160

Closed eliottchampault closed 1 year ago

eliottchampault commented 1 year ago

Hello there,

Thank you so much for this amazing package. I am sorry to create and issue as this is more of a question.

Would it be possible to have a default answer for the ask() method? Something "a la" Symfony\Component\Console\Question\ConfirmationQuestion; where the second param (I believe optional) is the default aswer in case the user press the 'return' key.

Let me know.

All the best

Eliott

xiCO2k commented 1 year ago

Hey Elliot, we will probably remove ask from Termwind core api, and it will have its own plugin in the future with all of that support.

Thanks.

eliottchampault commented 1 year ago

Excellent.

Is there a roadmap for Termwind?

I would love to know where this is heading as I am starting to use it heavily.

Best

Eliott

PS: sorry to be reaching you like this...

marios88 commented 1 year ago

For anyone still looking a quick default like functionality you can easily extend ask like this

function ask(string $question, mixed $default = NULL): mixed {
    $return = \Termwind\ask($question, NULL);
    if ($return === '') {
        return $default;
    }

    return $return;
}