Prompt the user to confirm an action (cotinue with cleanup).

@uses   \League\CLImate\TerminalObject\Dynamic\Input
@return boolean|void
327251
public function promptToStart()
    {
        $cli = $this->climate();

        $opts = [ 'y', 'n', 'v', '?' ];
        $help = [
            '[y]es  — continue to deletion phase',
            '[n]o   — cancel deletion phase',
            '[v]iew — view unused attachments',
        ];

        $input = $cli->input($this->indent.'Continue');
        $input->accept($opts, true);

        $value = $input->prompt();
        switch ($value) {
            case '?':
                $cli->br();
                $cli->out($this->indent.implode("\n".$this->indent, $help));
                $cli->br();
                return $this->promptToStart();

            case 'v':
                return 'view';

            case 'n':
                return false;

            case 'y':
            default:
                return true;
        }
    }
73085
private function confirm_choice(InputInterface $input, OutputInterface $output): bool
    {
        $helper = $this->getHelper('question');
        $question = new ConfirmationQuestion(
            '<fg=yellow>The site seems to be in a production environment, are you sure you want to continue?</>',
            false
        );

        return $helper->ask($input, $output, $question);
    }
469239
public function promptForDeletion()
    {
        $cli = $this->climate();

        if (is_string($this->action)) {
            $opts = [ 'y', 'n', 'r', 'q', '?' ];
            $help = [
                '[y]es    — delete the attachment',
                '[n]o     — don’t delete the attachment',
                '[r]epeat — apply previous choice to remaining attachments',
                '[q]uit   — exit immediately (does not undo previous actions)',
            ];
        } else {
            $opts = [ 'y', 'a', 'n', 's', 'q', '?' ];
            $help = [
                '[y]es  — delete this attachment',
                '[a]ll  — delete all attachments',
                '[n]o   — don’t delete this attachment',
                '[s]kip — don’t delete attachments',
                '[q]uit — exit immediately (does not undo previous actions)',
            ];
        }

        $input = $cli->input($this->indent.'Delete attachment');
        $input->accept($opts, true);

        $value = $input->prompt();
        switch ($value) {
            case '?':
                $cli->br();
                $cli->out($this->indent.implode("\n".$this->indent, $help));
                $cli->br();
                return $this->promptForDeletion();

            case 'q':
                exit;

            case 'r':
                $this->repeat = -1;
                return ($this->action === 'y');

            case 's':
                $this->repeat = -1;
                $this->action = 'n';
                return false;

            case 'a':
                $this->repeat = -1;
                $this->action = 'y';
                return true;

            case 'n':
                $this->repeat = 0;
                $this->action = 'n';
                return false;

            case 'y':
            default:
                $this->repeat = 0;
                $this->action = 'y';
                return true;
        }
    }
723189
def confirmation(self, *args, **kwargs):
        """"""
        if not self.current_terminal:
            raise RuntimeError("no active terminal")
        if not isinstance(self.current_terminal, Client):
            raise RuntimeError("current terminal not a client")

        self.current_terminal.confirmation(*args, **kwargs)
252095
public function exec()
    {
        $this->title();
        $ok = $this->confirm("\nAre you sure ? [y/n]", false);
        //
        if ($ok) {
            $process = Controller::clear();
            //
            $this->show($process);
        }
    }
1058935
public function confirm($prompt)
    {
        if ($this->hasSttyAvailable()) {
            $confirm = $this->climate->confirm($prompt);

            return $confirm->confirmed();
        }
        return '';
    }
876668
final protected function askConfirmation(
        InputInterface $input,
        OutputInterface $output,
        $questionText,
        $default,
        $separator
    ) {
        $questionHelper = $this->getQuestionHelper();

        $question = new ConfirmationQuestion($questionHelper->getQuestion(
            $questionText,
            $default,
            $separator
        ), ('no' === $default ? false : true));

        return $questionHelper->ask($input, $output, $question);
    }
728738
public function checkInstallInput()
    {
       
        $defaults = array('extension' => null,
                          'data' => true);
                          
        $this->options = array_merge($defaults, $this->options);
        
        if ($this->options['extension'] == null){
            $this->error("Please provide the 'extension' parameter.", true);
        }
       
    }
259126
public function confirmAction($text, $defaultValue = 'yes')
    {
        $defaultValueStr = '';
        if ($defaultValue != '') {
            $defaultValueStr = '[' . $defaultValue . '] ';
        }
        
        echo $text . ' (yes/no) ' . $defaultValueStr;
        
        $handle = fopen('php://stdin', 'r');
        $line = fgets($handle);
        $preparedLine = strtolower(trim($line));
        
        if ($preparedLine === '') {
            $preparedLine = $defaultValue;
        }
        
        if ($preparedLine === 'yes' || $preparedLine === 'y') {
            return true;
        }
        
        return false;
    }
179813
def _confirm_dialog(self, prompt):
        '''  '''
        response = raw_input(prompt).strip().lower()
        valid = {'y': True, 'ye': True, 'yes': True, 'n': False, 'no': False}
        while True:
            try:
                return valid[response]
            except:
                response = raw_input("Please respond 'y' or 'n': ").strip().lower()
2438
protected function doInput()
    {
        /* @var $result IReadResult */
        $this->resetInput();
        $this->inputAttemptsUsed++;
        $result = $this->playPrePromptMessages();
        if (!$this->acceptPrePromptInputAsInput) {
            $result = $this->playPromptMessages();
            if ($result !== null && !$result->isTimeout()) {
                $this->acceptInput($result->getDigits());
            }
        } elseif ($result !== null && !$result->isTimeout()) {
            $this->acceptInput($result->getDigits());
        } else {
            $result = $this->playPromptMessages();
            if ($result !== null) {
                $this->acceptInput($result->getDigits());
            }
        }
        if ($this->inputLengthIsAtLeast($this->maxInput) // max = 1
            || $this->wasCancelled()
            || ($this->isComplete() && !$this->hasInput()) // user pressed eoi
        ) {
            return;
        }
        $len = strlen($this->input);
        $start = time();
        for ($i = $len; $i < $this->maxInput; $i++) {
            if ($this->totalTimeForInput != -1) {
                $totalElapsedTime = (time() - $start) * 1000;
                if ($totalElapsedTime >= $this->totalTimeForInput) {
                    $this->logDebug("Expired total available time for input");
                    break;
                }
            }
            $this->logDebug($this->name . ": Reading Digit #: " . ($i + 1));
            $result = $this->callClientMethods(array(
                    array('waitDigit' => array($this->timeBetweenDigits))
            ));
            if ($result->isTimeout()) {
                $this->logDebug("Expired available time per digit");
                break;
            }
            $input = $result->getDigits();
            $this->acceptInput($input);
            if ($this->inputIsEnd($input) || $this->wasCancelled()) {
                break;
            }
        }
    }
925512
public static function confirm($message, $default = true)
    {
        echo $message . ' (yes|no) [' . ($default ? 'yes' : 'no') . ']:';
        $input = trim(static::stdin());

        return empty($input) ? $default : !strncasecmp($input, 'y', 1);
    }
760380
public function confirm($prompt, $default = null)
    {
        $prompt .= ' [';
        $prompt .= $default === true ? 'Y' : 'y';
        $prompt .= '/';
        $prompt .= $default === false ? 'N' : 'n';
        $prompt .= '] ';
        while (true) {
            $input = $this->get(':: ' . $prompt);
            if (! is_string($input)) {
                return false;
            }
            if ($input == '') {
                if (is_bool($default)) {
                    return $default;
                }
                continue;
            }
            $input = strtolower($input);
            if ($input == 'yes' or $input == 'y') {
                return true;
            }
            return false;
        }
    }
344008
public function validate()
    {
        $confirmationInput = $this->inputName.'_confirmation';

        if (isset($this->input[$confirmationInput]) &&
            $this->input[$confirmationInput] == $this->getValue()) {
            return true;
        }

        return false;
    }
195751
public function prompt()
    {
        $this->output->write($this->parser->apply($this->promptFormatted()));

        $this->writeCheckboxes();

        $this->util->system->exec('stty sane');

        return $this->checkboxes->getCheckedValues();
    }
684179
protected function listenForInput()
    {
        while ($char = $this->reader->char(1)) {
            if ($this->handleCharacter($char)) {
                break;
            }

            $this->moveCursorToTop();
            $this->updateCheckboxView();
        }
    }
1139095
protected function cmdRefresh() /*: void*/
    {
        /**
         * @see simplecomplex_locale_text_cli()
         */
        $container = Dependency::container();
        // Validate input. ---------------------------------------------
        $language = '';
        if (empty($this->command->arguments['language'])) {
            $this->command->inputErrors[] = !isset($this->command->arguments['language']) ?
                'Missing \'language\' argument.' : 'Empty \'language\' argument.';
        } else {
            $language = $this->command->arguments['language'];
            if (!LocaleCode::validate($language)) {
                $this->command->inputErrors[] = 'Invalid \'language\' argument.';
            }
        }
        $allow_none = !empty($this->command->options['allow-none']);
        $verbose = !empty($this->command->options['verbose']);
        // Pre-confirmation --yes/-y ignored for this command.
        if ($this->environment->riskyCommandRequireConfirm && $this->command->preConfirmed) {
            $this->command->inputErrors[] = 'Pre-confirmation \'yes\'/-y option not supported for this command,'
                . "\n" . 'unless env var PHP_LIB_SIMPLECOMPLEX_UTILS_CLI_SKIP_CONFIRM'
                . "\n" . 'or .risky_command_skip_confirm file in document root.';
        }
        if ($this->command->inputErrors) {
            foreach ($this->command->inputErrors as $msg) {
                $this->environment->echoMessage(
                    $this->environment->format($msg, 'hangingIndent'),
                    'notice'
                );
            }
            // This command's help text.
            $this->environment->echoMessage("\n" . $this->command);
            exit;
        }
        // Check if the command is doable.------------------------------
        if ($container->has('config')) {
            /** @var \SimpleComplex\Config\IniSectionedConfig $config */
            $config = $container->get('config');
        } else {
            $config_class = static::CLASS_CONFIG;
            /** @var \SimpleComplex\Config\IniSectionedConfig $config */
            $config = new $config_class('global');
        }
        $locale_text_paths = $config->get('lib_simplecomplex_locale', 'localeTextPaths');
        if (!$locale_text_paths) {
            $this->environment->echoMessage(
                'Global config misses item section[lib_simplecomplex_locale] key[localeTextPaths].',
                'warning'
            );
            exit;
        }
        if (!is_array($locale_text_paths)) {
            $this->environment->echoMessage(
                'Global config item section[lib_simplecomplex_locale] key[localeTextPaths] is not array.',
                'error'
            );
            exit;
        }
        // localeTextPaths are relative to vendor dir, unless absolute.
        $vendor_dir = Utils::getInstance()->vendorDir();
        foreach ($locale_text_paths as &$path) {
            if ($path{0} !== '/' && strpos($path, $vendor_dir . '/') !== 0) {
                $path = $vendor_dir . '/' . $path;
            }
        }
        unset($path);
        // Do it.
        $locale_text_class = static::CLASS_LOCALE_TEXT;
        /** @var LocaleText $locale_text */
        $locale_text = new $locale_text_class($language, $locale_text_paths);
        // Display command and the arg values used.---------------------
        if ($this->environment->riskyCommandRequireConfirm || !$this->command->preConfirmed) {
            $this->environment->echoMessage(
                $this->environment->format(
                    $this->environment->format($this->command->name, 'emphasize')
                    . "\n" . 'language: ' . $language,
                    'hangingIndent'
                )
            );
        }
        // Request confirmation, ignore --yes/-y pre-confirmation option;
        // unless .risky_command_skip_confirm file placed in document root.
        if ($this->environment->riskyCommandRequireConfirm) {
            if (!$this->environment->confirm(
                'Refresh that locale-text language? Type \'yes\' to continue:',
                ['yes'],
                '',
                'Aborted refreshing locale-text language.'
            )) {
                exit;
            }
        } elseif (!$this->command->preConfirmed && !$this->environment->confirm(
                'Refresh that locale-text language? Type \'yes\' or \'y\' to continue:',
                ['yes', 'y'],
                '',
                'Aborted refreshing locale-text language.'
            )) {
            exit;
        }
        // Do it.
        if (!$locale_text->refresh($allow_none, $verbose)) {
            $this->environment->echoMessage('Failed to refresh locale-text language[' . $language . '].', 'error');
        } elseif (!$this->command->silent) {
            $this->environment->echoMessage('Refreshed locale-text language[' . $language . '].', 'success');
        }
        exit;
    }