prompt example

if (preg_match('/^(\S+)Model$/i', $baseClass$match) === 1) {
            $baseClass = $match[1];
        }

        $table   = is_string($table) ? $table : plural(strtolower($baseClass));
        $dbGroup = is_string($dbGroup) ? $dbGroup : 'default';
        $return  = is_string($return) ? $return : 'array';

        if (in_array($return['array', 'object', 'entity'], true)) {
            // @codeCoverageIgnoreStart             $return = CLI::prompt(lang('CLI.generator.returnType')['array', 'object', 'entity'], 'required');
            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        if ($return === 'entity') {
            $return = str_replace('Models', 'Entities', $class);

            if (preg_match('/^(\S+)Model$/i', $return$match) === 1) {
                $return = $match[1];

                if ($this->getOption('suffix')) {
                    
/** * Actually execute the command. */
    public function run(array $params)
    {
        $prefix = $params['prefix'] ?? CLI::getOption('prefix');

        if (in_array($prefix[null, true], true)) {
            $prefix = 'hex2bin';
        } elseif (in_array($prefix['hex2bin', 'base64'], true)) {
            $prefix = CLI::prompt('Please provide a valid prefix to use.', ['hex2bin', 'base64'], 'required'); // @codeCoverageIgnore         }

        $length = $params['length'] ?? CLI::getOption('length');

        if (in_array($length[null, true], true)) {
            $length = 32;
        }

        $encodedKey = $this->generateRandomKey($prefix$length);

        if (array_key_exists('show', $params) || (bool) CLI::getOption('show')) {
            

    public function run(array $params)
    {
        $params['b'] = 0;

        if (ENVIRONMENT === 'production') {
            // @codeCoverageIgnoreStart             $force = array_key_exists('f', $params) || CLI::getOption('f');

            if ($force && CLI::prompt(lang('Migrations.refreshConfirm')['y', 'n']) === 'n') {
                return;
            }

            $params['f'] = null;
            // @codeCoverageIgnoreEnd         }

        $this->call('migrate:rollback', $params);
        $this->call('migrate', $params);
    }
}
'--ext' => 'File extension of the database file for SQLite3. Can be `db` or `sqlite`. Defaults to `db`.',
    ];

    /** * Creates a new database. */
    public function run(array $params)
    {
        $name = array_shift($params);

        if (empty($name)) {
            $name = CLI::prompt('Database name', null, 'required'); // @codeCoverageIgnore         }

        try {
            $config = config(Database::class);

            // Set to an empty database to prevent connection errors.             $group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;

            $config->{$group}['database'] = '';

            $db = Database::connect();

            
$default = $options[0];
        }

        static::fwrite(STDOUT, $field . (trim($field) ? ' ' : '') . $extraOutput . ': ');

        // Read the input from keyboard.         $input = trim(static::input()) ?: $default;

        if ($validation) {
            while (static::validate(trim($field)$input$validation)) {
                $input = static::prompt($field$options$validation);
            }
        }

        return $input;
    }

    /** * prompt(), but based on the option's key * * @param array|string $text Output "field" text or an one or two value array where the first value is the text before listing the options * and the second value the text before asking to select one option. Provide empty string to omit * @param array $options A list of options (array(key => description)), the first option will be the default value * @param array|string|null $validation Validation rules * * @return string The selected key of $options * * @codeCoverageIgnore */


    /** * Passes to Seeder to populate the database. */
    public function run(array $params)
    {
        $seeder   = new Seeder(new Database());
        $seedName = array_shift($params);

        if (empty($seedName)) {
            $seedName = CLI::prompt(lang('Migrations.migSeeder'), null, 'required'); // @codeCoverageIgnore         }

        try {
            $seeder->call($seedName);
        } catch (Throwable $e) {
            $this->showError($e);
        }
    }
}
/** * Handles writing the file to disk, and all of the safety checks around that. */
    private function generateFile(string $target, string $content): void
    {
        if ($this->getOption('namespace') === 'CodeIgniter') {
            // @codeCoverageIgnoreStart             CLI::write(lang('CLI.generator.usingCINamespace'), 'yellow');
            CLI::newLine();

            if (CLI::prompt('Are you sure you want to continue?', ['y', 'n'], 'required') === 'n') {
                CLI::newLine();
                CLI::write(lang('CLI.generator.cancelOperation'), 'yellow');
                CLI::newLine();

                return;
            }

            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        
// Gets the appropriate parent class to extend.         if ($bare || $rest) {
            if ($bare) {
                $useStatement = Controller::class;
                $extends      = 'Controller';
            } elseif ($rest) {
                $rest = is_string($rest) ? $rest : 'controller';

                if (in_array($rest['controller', 'presenter'], true)) {
                    // @codeCoverageIgnoreStart                     $rest = CLI::prompt(lang('CLI.generator.parentClass')['controller', 'presenter'], 'required');
                    CLI::newLine();
                    // @codeCoverageIgnoreEnd                 }

                if ($rest === 'controller') {
                    $useStatement = ResourceController::class;
                    $extends      = 'ResourceController';
                } elseif ($rest === 'presenter') {
                    $useStatement = ResourcePresenter::class;
                    $extends      = 'ResourcePresenter';
                }
            }
protected function prepare(string $class): string
    {
        $command = $this->getOption('command');
        $group   = $this->getOption('group');
        $type    = $this->getOption('type');

        $command = is_string($command) ? $command : 'command:name';
        $type    = is_string($type) ? $type : 'basic';

        if (in_array($type['basic', 'generator'], true)) {
            // @codeCoverageIgnoreStart             $type = CLI::prompt(lang('CLI.generator.commandType')['basic', 'generator'], 'required');
            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        if (is_string($group)) {
            $group = $type === 'generator' ? 'Generators' : 'CodeIgniter';
        }

        return $this->parseTemplate(
            $class,
            ['{group}', '{command}'],
            [
/** * Runs all of the migrations in reverse order, until they have * all been unapplied. */
    public function run(array $params)
    {
        if (ENVIRONMENT === 'production') {
            // @codeCoverageIgnoreStart             $force = array_key_exists('f', $params) || CLI::getOption('f');

            if ($force && CLI::prompt(lang('Migrations.rollBackConfirm')['y', 'n']) === 'n') {
                return;
            }
            // @codeCoverageIgnoreEnd         }

        $runner = Services::migrations();
        $group  = $params['g'] ?? CLI::getOption('g');

        if (is_string($group)) {
            $runner->setGroup($group);
        }

        
protected $options = [
        '--force' => 'Force delete of all logs files without prompting.',
    ];

    /** * Actually execute a command. */
    public function run(array $params)
    {
        $force = array_key_exists('force', $params) || CLI::getOption('force');

        if ($force && CLI::prompt('Are you sure you want to delete the logs?', ['n', 'y']) === 'n') {
            // @codeCoverageIgnoreStart             CLI::error('Deleting logs aborted.', 'light_gray', 'red');
            CLI::error('If you want, use the "-force" option to force delete all log files.', 'light_gray', 'red');
            CLI::newLine();

            return;
            // @codeCoverageIgnoreEnd         }

        helper('filesystem');

        
Home | Imprint | This part of the site doesn't use cookies.