Parse the answer that was given via the prompt.

@param string $choice
349965
protected function parseChoice($choice)
    {
        list($type, $value) = explode(': ', strip_tags($choice));

        if ($type === 'Provider') {
            $this->provider = $value;
        } elseif ($type === 'Tag') {
            $this->tags = [$value];
        }
    }
1049073
private function isEqual($choice, $givenChoice)
    {
        if ($choice === $givenChoice) {
            return true;
        }

        if ($this->getIdentifierValues($choice) === $this->getIdentifierValues($givenChoice)) {
            return true;
        }

        return false;
    }
1049234
public function ask(string $prompt, array $validAnswers = [], string $default = null)
    {
        if ($validAnswers) {
            $answers = [];
            foreach ($validAnswers as $v) {
                if ($default && $default === $v) {
                    $answers[] = '[' . $v . ']';
                } else {
                    $answers[] = $v;
                }
            }
            $prompt .= ' (' . implode('/', $answers) . ')';
        }

        $prompt .= ' ';

        if ($this->style) {
            echo $this->formatter->getStartMark($this->style);
        }

        $answer = null;
        while (true) {
            $answer = trim($this->console->readLine($prompt));
            if ($validAnswers) {
                if (in_array($answer, $validAnswers, true)) {
                    break;
                }

                if (trim($answer) === '' && $default) {
                    $answer = $default;
                    break;
                }
                continue;
            }
            break;
        }

        if ($this->style) {
            echo $this->formatter->getClearMark();
        }

        return $answer;
    }
948767
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
    {
        return parent::choice($this->setTextPrompt($question), $choices, $default, $attempts, $multiple);
    }
128400
public static function prompt()
    {
        $stdin = fopen('php://stdin', 'r');
        $answer = self::trimAnswer(fgets($stdin, 4096));
        fclose($stdin);

        return $answer;
    }
1147209
public function evaluateQuestion(array $question, PhpStringParser $parser, GeneratorDataObject $generator)
    {
        return $this->getInstance($question)->ask($question, $parser, $generator);
    }
536212
protected function select($text, $choices, $default = null)
    {
        $question = new ChoiceQuestion($text, $choices, $default);

        return $this->getHelper('question')->ask($this->input, $this->output, $question);
    }
1020857
static public function choice($value, array $choices, $message = null, $propertyPath = null)
        {
            if (!Arrays::in($value, $choices, true)) {
                $message = $message ?: sprintf(
                    'Value "%s" is not an element of the valid values: %s',
                    static::stringify($value),
                    implode(", ", array_map('Assert\Assertion::stringify', $choices))
                );

                throw static::createException($value, $message, static::INVALID_CHOICE, $propertyPath, array('choices' => $choices));
            }
        }
873725
protected function lookup_choice($choice) {
        if (array_key_exists($choice, $this->choices)) {
            // Easy case: choice is a key in the choices array.
            return $choice;
        } else {
            // But choice can also be the id of a shortanser correct answer
            // without been a key of the choices array, in that case we need
            // to first find the shortanswer id, then find the choices index
            // associated to it.
            $questionid = array_search($choice, $this->rightanswerid);
            if ($questionid) {
                return $this->right[$questionid];
            }
        }
        return null;
    }
136107
public function optionOrAsk($option, $question, $default = null)
    {
        $value = $this->input->getOption($option);
        if ($value === null || Str::likeEmpty($value)) {
            $value = $this->ask($question, $default);
        }

        return $value;
    }
966337
private function getQuestionString(InputOption $option, $default)
    {
        if ('' !== (string) $default) {
            if (stripos($option->getName(), 'password') !== false) {
                return sprintf('%s? [<options=bold>HIDDEN</>]: ', $option->getDescription(), $default);
            }

            return sprintf('%s? [<options=bold>%s</>]: ', $option->getDescription(), $default);
        }

        return sprintf('%s?: ', $option->getDescription());
    }
989405
protected function parseOptionString($string)
	{
		// Use the first "?" as an alias for the "optional" option
		$string = preg_replace('(^\\?)', ';optional', $string);

		$options = [];
		foreach (preg_split('#;+#', $string, -1, PREG_SPLIT_NO_EMPTY) as $pair)
		{
			$pos = strpos($pair, '=');
			if ($pos === false)
			{
				// Options with no value are set to true, e.g. {FOO;useContent}
				$k = $pair;
				$v = true;
			}
			else
			{
				$k = substr($pair, 0, $pos);
				$v = substr($pair, 1 + $pos);
			}

			$options[$k] = $v;
		}

		return $options;
	}
1225507
public function askWithCompletion($question, array $choices, $default = null, $attempts = null, $strict = false)
    {
        $question = new Question($question, $default);
        $question->setMaxAttempts($attempts)->setAutocompleterValues($choices);

        if ($strict) {
            $question->setValidator(function($result) use ($choices) {
                if (!in_array($result, $choices)) {
                    throw new \InvalidArgumentException(sprintf(
                        'The provided answer is ambiguous. Value should be one of %s',
                        implode(' or ', $choices)));
                }

                return $result;
            });
        }

        return $this->askQuestion($question);
    }
560530
def choice_prompt(prompt, choices=None, choice=None):
    '''
    
    '''
    if not choices:
        choices = ["y", "n", "Y", "N"]

    print(prompt)
    get_input = getattr(__builtins__, 'raw_input', input)
    pretty_choices = '/'.join(choices)
    message = 'Please enter your choice [%s] : ' %(pretty_choices)
    while choice not in choices:
        choice = get_input(message).strip()

        # If the option isn't valid, this is shown next
        message = "Please enter a valid option in [%s]" %(pretty_choices)    
    return choice
800931
public function validate($value)
    {
        return in_array($value, $this->choices) ? Ok::unit() : Error::unit([ Error::INVALID_CHOICE ]);
    }
766008
public function evaluateQuestion(array $question, PhpStringParser $parser, GeneratorDataObject $generator)
    {
        $iterator       = $this->iteratorValidator->retrieveValidIteration($question, $generator, $parser);
        $iteratorParser = clone $parser;

        foreach ($iterator as $iteration) {
            $iteratorParser->addVariable('iteration', $iteration);

            $origine            = $iteratorParser->parse($question['iteration']['retrieveBy']);
            $responseCollection = new PredefinedResponseCollection();

            foreach ($question['iteration']['response']['predefined'] as $predefinedResponse) {
                $responseCollection->append(
                    new PredefinedResponse(
                        $predefinedResponse['response'],
                        $iteratorParser->parse($predefinedResponse['text']),
                        $predefinedResponse['response']
                    )
                );
            }

            $questionWithPredefinedResponse = new QuestionWithPredefinedResponse(
                $iteratorParser->parse($question['iteration']['text']),
                'set_predefined_' . ucfirst($question['dtoAttribute']) . $origine,
                $responseCollection
            );

            $questionWithPredefinedResponse->setDefaultResponse(
                (isset($question['iteration']['response']['default']) === true) ?
                    $iteratorParser->parse($question['iteration']['response']['default']) : null
            )->setRequired($question['required'])
             ->setResponseType(new QuestionResponseTypeEnum($question['iteration']['response']['type']));

            $response = $this->context->askCollection($questionWithPredefinedResponse);

            $questionName = $question['setter'];
            if ($response !== null) {
                $generator->getDto()->$questionName($origine, $response);
            }
        }

        return $generator;
    }
671360
public function choices()
    {
        $choices = $this->p()->choices();
        foreach ($choices as $ident => $choice) {
            $choice = $this->parseChoice($ident, $choice);

            if (isset($choice['active']) && $choice['active'] === false) {
                continue;
            }

            if (!is_array($choice)) {
                continue;
            }

            yield $ident => $choice;
        }
    }