StackFormation\Command\AbstractCommand::interactAskForStack PHP Method

interactAskForStack() public method

public interactAskForStack ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output, $nameFilter = null, $statusFilter = null )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    public function interactAskForStack(InputInterface $input, OutputInterface $output, $nameFilter = null, $statusFilter = null)
    {
        $stack = $input->getArgument('stack');
        if (empty($stack)) {
            $choices = $this->getStacks($nameFilter, $statusFilter);
            if (count($choices) == 0) {
                throw new \Exception('No valid stacks found.');
            }
            if (count($choices) == 1) {
                $stack = end($choices);
            } else {
                $helper = $this->getHelper('question');
                $question = new ChoiceQuestion('Please select a stack', $choices);
                $question->setErrorMessage('Stack %s is invalid.');
                $stack = $helper->ask($input, $output, $question);
            }
            $output->writeln('Selected Stack: ' . $stack);
            $input->setArgument('stack', $stack);
        }
        return $stack;
    }