src/Joomlatools/Console/Command/Site/AbstractSite.php
protected function _ask(InputInterface $input, OutputInterface $output, $label, $default = '', $required = false, $hidden = false)
    {
        $helper  = $this->getHelper('question');
        $text    = $label;

        if (is_array($default)) {
            $defaultValue = $default[0];
        }
        else $defaultValue = $default;

        if (!empty($defaultValue)) {
            $text .= ' [default: <info>' . $defaultValue . '</info>]';
        }

        $text .= ': ';

        if (is_array($default)) {
            $question = new Question\ChoiceQuestion($text, $default, 0);
        }
        else $question = new Question\Question($text, $default);

        if ($hidden === true) {
            $question->setHidden(true);
        }

        $answer = $helper->ask($input, $output, $question);

        if ($required && empty($answer)) {
            return $this->_ask($input, $output, $label, $default, $hidden);
        }

        return $answer;
    }
protected function _ask(InputInterface $input, OutputInterface $output, $label, $default = '', $required = false, $hidden = false)
    {
        $helper  = $this->getHelper('question');
        $text    = $label;

        if (is_array($default)) {
            $defaultValue = $default[0];
        }
        else $defaultValue = $default;

        if (!empty($defaultValue)) {
            $text .= ' [default: <info>' . $defaultValue . '</info>]';
        }

        $text .= ': ';

        if (is_array($default)) {
            $question = new Question\ChoiceQuestion($text, $default, 0);
        }
        else $question = new Question\Question($text, $default);

        if ($hidden === true) {
            $question->setHidden(true);
        }

        $answer = $helper->ask($input, $output, $question);

        if ($required && empty($answer)) {
            return $this->_ask($input, $output, $label, $default, $hidden);
        }

        return $answer;
    }
protected function _ask ( InputInterface $ input , OutputInterface $ output , $ label , $ default = '' , $ required = false , $ hidden = false ) { $ helper = $ this -> getHelper ( 'question' ) ; $ text = $ label ; if ( is_array ( $ default ) ) { $ defaultValue = $ default [ 0 ] ; } else $ defaultValue = $ default ; if ( ! empty ( $ defaultValue ) ) { $ text .= ' [default: <info>' . $ defaultValue . '</info>]' ; } $ text .= ': ' ; if ( is_array ( $ default ) ) { $ question = new Question \ ChoiceQuestion ( $ text , $ default , 0 ) ; } else $ question = new Question \ Question ( $ text , $ default ) ; if ( $ hidden === true ) { $ question -> setHidden ( true ) ; } $ answer = $ helper -> ask ( $ input , $ output , $ question ) ; if ( $ required && empty ( $ answer ) ) { return $ this -> _ask ( $ input , $ output , $ label , $ default , $ hidden ) ; } return $ answer ; }
Prompt user to fill in a value

@param InputInterface $input
@param OutputInterface $output
@param $label    string          The description of the value
@param $default  string|array    The default value. If array given, question will be multiple-choice and the first item will be default. Can also be empty.
@param bool $required
@param bool $hidden  Hide user input (useful for passwords)

@return string   Answer
Prompt user to fill in a value