/**
* Prompts the user for input, and returns it.
*
* @param string $prompt Prompt text.
* @param string|null $options String of options. Pass null to omit.
* @param string|null $default Default input value. Pass null to omit.
* @return string Either the default value, or the user-provided input.
*/
protected function _getInput($prompt, $options, $default)
{
$optionsText = '';
if (isset($options)) {
$optionsText = " {$options} ";
}
$defaultText = '';
if ($default !== null) {
$defaultText = "[{$default}] ";
}
$this->_out->write('<question>' . $prompt . "</question>{$optionsText}\n{$defaultText}> ", 0);
$result = $this->_in->read();
$result = trim($result);
if ($default !== null && ($result === '' || $result === null)) {
return $default;
}
return $result;
}