|
@@ -32,7 +32,7 @@ class DialogHelper extends Helper
|
|
public function ask(OutputInterface $output, $question, $default = null)
|
|
public function ask(OutputInterface $output, $question, $default = null)
|
|
{
|
|
{
|
|
// @codeCoverageIgnoreStart
|
|
// @codeCoverageIgnoreStart
|
|
- $output->writeln($question);
|
|
|
|
|
|
+ $output->write($question);
|
|
|
|
|
|
$ret = trim(fgets(STDIN));
|
|
$ret = trim(fgets(STDIN));
|
|
|
|
|
|
@@ -78,12 +78,13 @@ class DialogHelper extends Helper
|
|
* @param string|array $question
|
|
* @param string|array $question
|
|
* @param callback $validator A PHP callback
|
|
* @param callback $validator A PHP callback
|
|
* @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
|
* @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
|
|
|
+ * @param string $default The default answer if none is given by the user
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*
|
|
*
|
|
* @throws \Exception When any of the validator returns an error
|
|
* @throws \Exception When any of the validator returns an error
|
|
*/
|
|
*/
|
|
- public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false)
|
|
|
|
|
|
+ public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null)
|
|
{
|
|
{
|
|
// @codeCoverageIgnoreStart
|
|
// @codeCoverageIgnoreStart
|
|
$error = null;
|
|
$error = null;
|
|
@@ -92,7 +93,7 @@ class DialogHelper extends Helper
|
|
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
|
|
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
|
|
}
|
|
}
|
|
|
|
|
|
- $value = $this->ask($output, $question, null);
|
|
|
|
|
|
+ $value = $this->ask($output, $question, $default);
|
|
|
|
|
|
try {
|
|
try {
|
|
return call_user_func($validator, $value);
|
|
return call_user_func($validator, $value);
|