public function confirm($questionText, $default = true)
    {
        $questionText .= ' <question>' . ($default ? '[Y/n]' : '[y/N]') . '</question> ';

        $yes = $this->input->hasOption('yes') && $this->input->getOption('yes');
        $no = $this->input->hasOption('no') && $this->input->getOption('no');
        if ($yes && !$no) {
            $this->output->writeln($questionText . 'y');
            return true;
        } elseif ($no && !$yes) {
            $this->output->writeln($questionText . 'n');
            return false;
        } elseif (!$this->input->isInteractive()) {
            $this->output->writeln($questionText . ($default ? 'y' : 'n'));
            return $default;
        }
        $question = new ConfirmationQuestion($questionText, $default);

        return $this->ask($this->input, $this->output, $question);
    }
public function confirm($questionText, $default = true)
    {
        $questionText .= ' <question>' . ($default ? '[Y/n]' : '[y/N]') . '</question> ';

        $yes = $this->input->hasOption('yes') && $this->input->getOption('yes');
        $no = $this->input->hasOption('no') && $this->input->getOption('no');
        if ($yes && !$no) {
            $this->output->writeln($questionText . 'y');
            return true;
        } elseif ($no && !$yes) {
            $this->output->writeln($questionText . 'n');
            return false;
        } elseif (!$this->input->isInteractive()) {
            $this->output->writeln($questionText . ($default ? 'y' : 'n'));
            return $default;
        }
        $question = new ConfirmationQuestion($questionText, $default);

        return $this->ask($this->input, $this->output, $question);
    }
public function confirm ( $ questionText , $ default = true ) { $ questionText .= ' <question>' . ( $ default ? '[Y/n]' : '[y/N]' ) . '</question> ' ; $ yes = $ this -> input -> hasOption ( 'yes' ) && $ this -> input -> getOption ( 'yes' ) ; $ no = $ this -> input -> hasOption ( 'no' ) && $ this -> input -> getOption ( 'no' ) ; if ( $ yes && ! $ no ) { $ this -> output -> writeln ( $ questionText . 'y' ) ; return true ; } elseif ( $ no && ! $ yes ) { $ this -> output -> writeln ( $ questionText . 'n' ) ; return false ; } elseif ( ! $ this -> input -> isInteractive ( ) ) { $ this -> output -> writeln ( $ questionText . ( $ default ? 'y' : 'n' ) ) ; return $ default ; } $ question = new ConfirmationQuestion ( $ questionText , $ default ) ; return $ this -> ask ( $ this -> input , $ this -> output , $ question ) ; }
Ask the user to confirm an action.

@param string          $questionText
@param bool            $default

@return bool
Ask the user to confirm an action .