ask() public method

Asks a question to the user
public ask ( string | array $question, string $default = null, array $autocomplete = null ) : string
$question string | array The question to ask. If an array each array item is turned into one line of a multi-line question
$default string The default answer if none is given by the user
$autocomplete array List of values to autocomplete. This only works if "stty" is installed
return string The user answer
 /**
  * @param string $question
  * @param \Closure $task
  * @return void
  */
 protected function askBeforeExecutingTask($question, \Closure $task)
 {
     $response = null;
     while (!in_array($response, array('y', 'n'))) {
         $response = strtolower($this->output->ask('<comment>' . $question . ' (y/n)</comment>'));
     }
     $this->output->outputLine();
     switch ($response) {
         case 'y':
             $task();
             break;
         case 'n':
             $this->output->outputLine('Skipping.');
             break;
     }
 }
 /**
  * Maps arguments delivered by the request object to the local controller arguments.
  *
  * @return void
  */
 protected function mapRequestArgumentsToControllerArguments()
 {
     /** @var Argument $argument */
     foreach ($this->arguments as $argument) {
         $argumentName = $argument->getName();
         if ($this->request->hasArgument($argumentName)) {
             $argument->setValue($this->request->getArgument($argumentName));
             continue;
         }
         if (!$argument->isRequired()) {
             continue;
         }
         $argumentValue = null;
         while ($argumentValue === null) {
             $argumentValue = $this->output->ask(sprintf('<comment>Please specify the required argument "%s":</comment> ', $argumentName));
         }
         if ($argumentValue === null) {
             $exception = new CommandException(sprintf('Required argument "%s" is not set.', $argumentName), 1306755520);
             $this->forward('error', HelpCommandController::class, ['exception' => $exception]);
         }
         $argument->setValue($argumentValue);
     }
 }