Read input information
@param  string $question 若不为空，则先输出文本
@param  bool   $nl true 会添加换行符 false 原样输出，不添加换行符
@return string
543743
public function read(string $question = '', bool $nl = false): string
    {
        return Console::read($question, $nl);
    }
1307273
public function askPassword($question)
    {
        $helper = $this->getHelper('question');

        $question = new Question($question);

        $question->setHidden(true);

        $question->setHiddenFallback(false);

        return $helper->ask($this->input, $this->getOutputInterface(), $question);
    }
315375
public function in($question = '')
	{
		$question ? : $this->question;

		if ($this->win)
		{
			if ($question)
			{
				$this->output->out()->out($question, false);
			}

			$value = rtrim(shell_exec($this->hiddenExe));

			$this->output->out();

			return $value;
		}

		// Using stty help us test this class.
		elseif ($this->findStty())
		{
			if ($question)
			{
				$this->output->out()->out($question, false);
			}

			// Get stty setting
			$setting = shell_exec('stty -g');

			shell_exec('stty -echo');

			$value = fread($this->inputStream, 8192);

			shell_exec(sprintf('stty %s', $setting));

			if ($value === false)
			{
				throw new \RuntimeException('Cannot get input value.');
			}

			$this->output->out();

			return rtrim($value);
		}

		// For linux & Unix system
		else
		{
			// Find shell.
			$shell = $this->findShell();

			if (!$shell)
			{
				throw new \RuntimeException("Can't invoke shell");
			}

			$this->output->out();

			// Using read to write password
			$read = sprintf('read -s -p "%s" mypassword && echo $mypassword', $question);

			// Here we use bash to handle this command.
			$command = sprintf("/usr/bin/env bash -c '%s'", $read);

			$value = rtrim(shell_exec($command));

			$this->output->out();

			return $value;
		}
	}
331940
protected function askConfirmation($question, InputInterface $input, OutputInterface $output) {
        if (!$this->getHelperSet()->has('question')) {
            return $this->getHelper('dialog')
                ->askConfirmation($output, '<question>' . $question . '</question>', 'y');
        }

        return $this->getHelper('question')
            ->ask($input, $output, new \Symfony\Component\Console\Question\ConfirmationQuestion($question));
    }
441820
public function ask(string $question, array $options): int
	{
		$options = array_values($options);

		$this->output->writeLn(trim($question));

		$this->output->write($this->buildOptionsList($options));

		$key = (int) $this->input->read() - 1;

		if(isset($options[$key]))
		{
			return $key;
		}

		return $this->ask($question, $options);
	}
176002
final protected function confirm($question, $defaultValue = true)
    {
        $indent = ($this->indent > 0) ? $this->indent : 0;
        $prompt = sprintf(' [<info>%s</info>]', $defaultValue ? 'yes' : 'no');
        $question = sprintf('%s%s%s: ', str_repeat(' ', 4 * $indent), $question, $prompt);

        $question = new ConfirmationQuestion($question, $defaultValue);
        return $this->getHelper('question')->ask($this->input, $this->output, $question);
    }
391999
public function in(string $question, string $default = '')
    {
        $formatted = sprintf('%s (%s):', $question, $default);

        return $this->handler->in($formatted, $default);
    }
200394
protected function prompt($question, $default)
    {
        try {
            return \cli\prompt($question, $default);
        } catch (\Exception $e) {
            WP_CLI::error($e->getMessage());
            die;
        }
    }
559728
protected function readquestions($text) {

        // This converts xml to big nasty data structure,
        // the 0 means keep white space as it is.
        try {
            $xml = xmlize($text, 0, 'UTF-8', true);
        } catch (xml_format_exception $e) {
            $this->error($e->getMessage(), '');
            return false;
        }

        $questions = array();

        $this->process_category($xml, $questions);

        $this->process_tf($xml, $questions);
        $this->process_mc($xml, $questions);
        $this->process_ma($xml, $questions);
        $this->process_fib($xml, $questions);
        $this->process_matching($xml, $questions);
        $this->process_essay($xml, $questions);

        return $questions;
    }
259413
public function setupQuestion($question)
    {
        $user = new User($this->db);
        $post = new Post($this->db);

        $question->img = $user->getGravatar($question->user);
        $question->title = $this->getMD($question->title);
        $question->tags = explode(',', $question->tags);

        $question->question = $post->getPost("questionId = ? AND type = ?", [$question->id, "question"]);
        $question->answers = $post->getAllPosts("questionId = ? AND type = ?", [$question->id, "answer"]);
        $question->answerCount = count($question->answers);


        return $question;
    }
1222436
protected function ask($question, $default = null, Closure $validator = null)
    {
        if ($default) {
            $question .= " [$default]";
        }

        $question = new Question($question . "\n > ", $default);

        if ($validator) {
            $question->setValidator($validator);
        }

        return trim($this->getHelper('question')->ask($this->input, $this->output, $question));
    }
87423
public function out($text = '', $nl = true)
    {
        $quiet = $this->console ? $this->console->get('quiet', false) : false;

        if (!$quiet) {
            $this->io->out($text, $nl);
        }

        return $this;
    }
1153724
public static function read($message = null, bool $nl = false, array $opts = []): string
    {
        if ($message) {
            self::write($message, $nl);
        }

        $opts = \array_merge([
            'length' => 1024,
            'stream' => \STDIN,
        ], $opts);

        return \file_get_contents($opts['stream'], $opts['length']);
    }
457936
public function input($question, $default = '', $options = [])
    {
        if (empty($default)) {
            $this->write($question . ' ');
        } elseif (empty($options)) {
            $this->write($question . ' [' . $default . '] ');
        } else {
            $available_options = [];
            foreach (strtolower($options) as $option) {
                if ($option === strtolower($default)) {
                    $option = strtoupper($option);
                }
                $available_options[] = $option;
            }
            $available_opts = rtrim(implode($available_options, '/'), '/');
            $this->write($question . ' [' . $available_opts . '] ');
        }
        $answer = rtrim(fgets(STDIN), PHP_EOL);
        if (empty($answer)) {
            return $default;
        }
        if (count($options) > 0) {
            if (!in_array(strtolower($answer), array_map('strtolower', $options))) {
                return $this->input($question, $default, $options);
            }
            return $answer;
        }
        return $answer;
    }
800448
public function askWithCompletion($question, array $choices, $default = null)
    {
        $helper = $this->getHelperSet()->get('question');

        $question = new Question("<question>$question</question> ", $default);

        $question->setAutocompleterValues($choices);

        return $helper->ask($this->input, $this->output, $question);
    }
351712
public function out($text = '', $nl = true)
	{
		fwrite(STDOUT, $this->processor->process($text) . ($nl ? "\n" : null));

		return $this;
	}
130095
public function ask($text, $response = '')
    {
        $helper = $this->getHelper('question');
        //
        $question = new Question($this->console->question($text.' '), $response);
        //
        return $helper->ask($this->input, $this->output, $question);
    }