thephpleague / climate

PHP's best friend for the terminal.
http://climate.thephpleague.com
MIT License
1.87k stars 126 forks source link

Input and confirm has no default values #181

Closed gugglegum closed 3 years ago

gugglegum commented 3 years ago

Sometimes it is useful to allow user select default variant just by pressing ENTER. And variants should be printed after question in brackets. For example: Are you sure? [y/N] Here uppercase N means this is default answer. Or: Enter the path of rsa key (/home/user/.ssh/id_rsa):

duncan3dc commented 3 years ago

Have you tried using defaultTo() with an input?

$default = '/home/user/.ssh/id_rsa';
$input = $climate->input('Enter the path of rsa key (' . $default . '): ');
$input->defaultTo($default);
$response = $input->prompt();