Form::confirm

Create a cli confirmation form input.

@param string             $name
@param string|Format|Text $question
@param bool               $required
196344
public function confirm($name, $question, $required = false)
    {
        if (is_string($question)) {
            output()->write(
                (new Format())
                    ->setString(rtrim(language()->getLine($question), '?') . ' (Y/N) ?')
                    ->setSpace(1)
            );
        } elseif ($question instanceof Format or $question instanceof Text) {
            output()->write($question . '?');
        }

        $standardInput = strtoupper(input()->standard());

        if ($required === true and ! in_array($standardInput, ['Y', 'N'])) {
            $requiredText = (new Format())
                ->setColor((new Color())->setBackground(Color::RED))
                ->setString(' ' . language()->getLine('REQUIRED') . ' ')
                ->setIndent(1)
                ->__toString();

            $this->confirm($name, str_replace($requiredText, '', $question) . $requiredText, $required);

            return;
        }

        $_POST[ $name ] = (bool)($standardInput === 'Y');
    }
493867
public function createCheck($constraint, $name = null)
    {
        $check = new Check($name, $constraint);
        $this->addCheck($check);

        return $check;
    }
790519
function cmd_confirm(args, done) {
    var seneca = this
    var why
    var userent = seneca.make(user_canon)

    userent.load$({ confirmcode: args.code }, function(err, user) {
      if (err) return done(err)

      if (user) {
        if (user.active) {
          user.confirmed = true
          user.save$(function(err, user) {
            if (err) return done(err)
            done(null, { ok: true, user: user })
          })
        } else {
          seneca.log.debug(
            'confirm/fail',
            (why = 'not-active'),
            args.code,
            user
          )
          return done(null, { ok: false, why: why, user: user })
        }
      } else {
        seneca.log.debug(
          'confirm/fail',
          (why = 'invalid-code'),
          args.code,
          user
        )
        return done(null, { ok: false, why: why })
      }
    })
  }
200394
protected function prompt($question, $default)
    {
        try {
            return \cli\prompt($question, $default);
        } catch (\Exception $e) {
            WP_CLI::error($e->getMessage());
            die;
        }
    }
1030331
protected function promptMigration($name)
    {
        $this->line('');

        if ($this->confirm('Would you like to create the migration for the model? [Yes|no]'))
        {
            $this->call('transit:migration', ['table' => str_plural($name)]);
        }
    }
460870
public function confirm($question, $yesScript, $noScript)
    {
        return $this->getConfirmLibrary(true)->confirm($question, $yesScript, $noScript);
    }
1126275
public function setOption($name, $shortcut = null, $inputRequired = false, $description = 'option does what?')
    {
        $inputRequired ? $inputRequired = InputOption::VALUE_REQUIRED :
            $inputRequired = InputOption::VALUE_OPTIONAL;

        $this->addOption($name, $shortcut, $inputRequired, $description);
    }
908150
public static function buildLabel($name, $label = '', $required = false)
        {
            $out = '';

            if (!empty($label)) {
                $class = 'control-label';
                $requiredLabel = '.req';
                $requiredSuffix = '<span class="required"><i class="icon-asterisk"></i></span>';
                $requiredPrefix = '';
                $requiredClass = 'labelrequired';

                if (false !== $required) {
                    $label = $requiredPrefix . $label . $requiredSuffix;
                    $class .= ' ' . $requiredClass;
                }

                $out .= static::label($name, $label, array('class' => $class));
            }

            return $out;
        }
430017
public function askUntillValid(string $prompt, callable $validationCallback)
    {
        $result = null;

        while($validationCallback($result) !== true) {
            $result = $this->readLine("$prompt");
        }
        return $result;
    }
535427
def confirm(self, question, default=False, true_answer_regex="(?i)^y"):
        
        return self._io.confirm(question, default, true_answer_regex)
283742
private function askAndSetNewPathValue($name)
    {
        $previous = $this->resolver->raw($name);
        $question = new Question('Enter new value for ' . $name, $previous);
        $question->setValidator(function ($value) use ($name, $previous) {
            $this->resolver->define($name, $value);
            // verify valid path.
            try {
                $this->resolver->resolve($name);
            } catch (\Exception $e) {
                $this->resolver->define($name, $previous); // revert path change
                throw $e;
            }
        });
        $this->io->askQuestionThenRemove($question);
    }
510367
public function check($provided, $name)
    {
        $provided = bindec($provided);
        return (bool)($provided & $this->getRight($name));
    }
336702
public function askConfirmation($text, InputInterface $input = null)
    {
        if ($this->dialogHelper instanceof QuestionHelper) {
            if (!$input) {
                throw new \InvalidArgumentException('With symfony 3, the input stream may not be null');
            }
            return $this->dialogHelper->ask($input, $this, new ConfirmationQuestion($text));
        }

        if ($this->dialogHelper instanceof DialogHelper) {
            return $this->dialogHelper->askConfirmation($this, $text);
        }

        throw new \RuntimeException("Invalid dialogHelper");

    }
227040
protected function confirm($text, $default = true)
    {
        $choices = $default ? 'Yn' : 'yN';
        $confirm = new ConfirmationQuestion("$text [$choices] ", $default);

        return $this->getHelper('question')->ask($this->input, $this->output, $confirm);
    }
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);
    }
176002
final protected function confirm($question, $defaultValue = true)
    {
        $indent = ($this->indent > 0) ? $this->indent : 0;
        $prompt = sprintf(' [<info>%s</info>]', $defaultValue ? 'yes' : 'no');
        $question = sprintf('%s%s%s: ', str_repeat(' ', 4 * $indent), $question, $prompt);

        $question = new ConfirmationQuestion($question, $defaultValue);
        return $this->getHelper('question')->ask($this->input, $this->output, $question);
    }
1119003
public function addValidation(string $name, string $validation): void{
        $this->validations[$name] = $validation;
    }