@param array $args
@param array $options

@return void
330840
public function execute(array $args = [], array $options = [])
    {
        $options += [
            'format' => $this->getDefaultFormat(),
            'encode' => 'raw',
        ];

        $s = $this->getConfigService();

        switch ($options['format']) {
            case 'env':
                $s->setDumper(new ConfigDumper\ShellEnvironmentConfigDumper());
                break;
            case 'json':
                $s->setDumper(new ConfigDumper\JsonConfigDumper());
                break;
            case 'php':
                $s->setDumper(new ConfigDumper\PhpConfigDumper());
                break;
            case 'serialized':
                $s->setDumper(new ConfigDumper\SerializedConfigDumper());
                break;
            case 'yaml':
                $s->setDumper(new ConfigDumper\YamlConfigDumper());
                break;
            default:
                throw new \RuntimeException(sprintf("Unsupported format '%s'", $options['format']), 3);
        }

        switch ($options['encode']) {
            case 'base64':
                $s->addDumpEncoder(new DumpEncoder\Base64DumpEncoder());
                break;
            case 'sha1':
                $s->addDumpEncoder(new DumpEncoder\Sha1DumpEncoder());
                break;
            case 'md5':
                $s->addDumpEncoder(new DumpEncoder\Md5DumpEncoder());
                break;
            case 'raw':
                break;
            default:
                throw new \RuntimeException(sprintf("Unsupported dump encoder '%s'", $options['encoder']), 3);
        }

        $s->addPrinter(new Printer\ConsolePrinter());

        $input = $this->getInput();

        if (null === $input) {
            throw new \RuntimeException('No input available for command', 10);
        }

        $output = $this->getOutput();

        if (null === $output) {
            throw new \RuntimeException('No output available for command', 11);
        }

        $s->processLoaded($input, $output, $this->getData());
    }
400814
public function execute(array $args, array $options = [])
    {
        $rootDir = null;
        if (isset($options['root-dir']) && !empty($options['root-dir'])) {
            $rootDir = $options['root-dir'];
        }
        StaticResource::createSymbolicLink($rootDir);
    }
587930
public function register($arguments, $options)
    {
        $method = array_shift($arguments);

        $this->setArguments($arguments);
        $this->setOptions($options);

        if (method_exists($this, $method)) {
            try {
                return $this->app->call([$this, $method]);
            } catch (Exception $e) {
                $this->error($e->getMessage());
            }
        }

        $this->error("You have to provide command argument [$this->signature <argument>].");
    }
726391
public function execute(array $args = [], array $options = [])
    {
        $d     = new Service\DebugService();
        $infos = $d->describe();
        $max   = 0;

        foreach ($infos as $section => $data) {
            foreach ($data as $k => $v) {
                $len = strlen($k);
                $max = $max < $len ? $len : $max;
            }
        }

        foreach ($infos as $section => $data) {
            echo sprintf('[%s]', strtoupper($section)).PHP_EOL.PHP_EOL;
            foreach ($data as $k => $v) {
                echo sprintf(' %'.((int) $max).'s:  %s', ucwords(str_replace('_', ' ', $k)), is_array($v) ? join(' ', $v) : (is_bool($v) ? ($v ? 'true' : 'false') : $v)).PHP_EOL;
            }
            echo PHP_EOL;
        }
    }
689505
public function write($messages, $options = 0)
    {
        $this->log($messages);
        $this->output->write($messages, false, $options);
    }
403946
public function execute(array $args, array $options = [])
    {
        $className = $args[0];

        $this->bootstrap($args, $options);

        if (!Util::isValidPhinxClassName($className)) {
            throw new \InvalidArgumentException(sprintf(
                'The migration class name "%s" is invalid. Please use CamelCase format.',
                $className
            ));
        }

        // get the migration path from the config
        $path = $this->getConfig()->getMigrationPath();

        if (!is_dir($path)) {
            $ask = new Dialog();
            if ($ask->confirm(Colour::colour('Create migrations directory?', [Colour::RED, Colour::HIGHLIGHT]))) {
                mkdir($path, 0755, true);
            }
        }

        $this->verifyMigrationDirectory($path);

        $path = realpath($path);

        if (!Util::isUniqueMigrationClassName($className, $path)) {
            throw new \InvalidArgumentException(sprintf(
                'The migration class name "%s" already exists',
                $className
            ));
        }

        // Compute the file path
        $fileName = Util::mapClassNameToFileName($className);
        $filePath = $path . DIRECTORY_SEPARATOR . $fileName;

        if (is_file($filePath)) {
            throw new \InvalidArgumentException(sprintf(
                'The file "%s" already exists',
                $filePath
            ));
        }

        // Get the alternative template and static class options from the command line, but only allow one of them.
        $altTemplate = $options['template'];
        $creationClassName = $options['class'];
        if ($altTemplate && $creationClassName) {
            throw new \InvalidArgumentException('Cannot use --template and --class at the same time');
        }

        // Verify the alternative template file's existence.
        if ($altTemplate && !is_file($altTemplate)) {
            throw new \InvalidArgumentException(sprintf(
                'The alternative template file "%s" does not exist',
                $altTemplate
            ));
        }

        if ($creationClassName) {
            // Supplied class does not exist, is it aliased?
            if (!class_exists($creationClassName)) {
                throw new \InvalidArgumentException(sprintf(
                    'The class "%s" does not exist',
                    $creationClassName
                ));
            }

            // Does the class implement the required interface?
            if (!is_subclass_of($creationClassName, self::CREATION_INTERFACE)) {
                throw new \InvalidArgumentException(sprintf(
                    'The class "%s" does not implement the required interface "%s"',
                    $creationClassName,
                    self::CREATION_INTERFACE
                ));
            }
        }

        // Determine the appropriate mechanism to get the template
        if ($creationClassName) {
            // Get the template from the creation class
            $creationClass = new $creationClassName();
            $contents = $creationClass->getMigrationTemplate();
        } else {
            // Load the alternative template if it is defined.
            $contents = file_get_contents($altTemplate ?: $this->getMigrationTemplateFilename());
        }

        // inject the class names appropriate to this migration
        $classes = [
            '$useClassName' => $this->getConfig()->getMigrationBaseClassName(false),
            '$className' => $className,
            '$version' => Util::getVersionFromFileName($fileName),
            '$baseClassName' => $this->getConfig()->getMigrationBaseClassName(true),
        ];
        $contents = strtr($contents, $classes);

        if (false === file_put_contents($filePath, $contents)) {
            throw new \RuntimeException(sprintf(
                'The file "%s" could not be written to',
                $path
            ));
        }

        // Do we need to do the post creation call to the creation class?
        if ($creationClassName) {
            $creationClass->postMigrationCreation($filePath, $className, $this->getConfig()->getMigrationBaseClassName());
        }

        Output::writeln('using migration base class ' . Colour::colour($classes['$useClassName'], Colour::GREEN));

        if (!empty($altTemplate)) {
            Output::writeln('using alternative template ' . Colour::colour($altTemplate, Colour::GREEN));
        } elseif (!empty($creationClassName)) {
            Output::writeln('using template creation class ' . Colour::colour($creationClassName, Colour::GREEN));
        } else {
            Output::writeln('using default template');
        }

        Output::writeln('created ' . str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $filePath));
    }
20284
protected static function execCommand($options, $cmd, array $args, $ifError)
    {
        if (is_array($options) && isset($options['path'])) {
            $cmd = $options['path'];
        } else {
            $executableFinder = new ExecutableFinder;
            $cmd = $executableFinder->find($cmd);
        }

        $out = '';
        $process = ProcessBuilder::create(array_merge(array($cmd), $args))->getProcess();
        if (isset($options['timeout'])) {
            $process->setTimeout($options['timeout']);
        }
        $process->run(function($type, $buffer) use (&$out) { $out .= $buffer; });

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($ifError."\n\n".$out);
        }
    }
254810
protected function setOptions(array $options = []): void
    {
        $this->options = $options;
        $this->configName = empty($options['cacheConfig']) ? static::DEFAULT_CONFIG : (string)$options['cacheConfig'];
        $this->skipCache = empty($this->options['cacheSkip']) ? false : (bool)$this->options['cacheSkip'];
    }
240219
public function run(array $options): void
    {
        // run once
        $this->___checkRun(new AppException("You cannot call App::run() anymore, it's already ".
                "called in skeleton/pub/index.php once"));

        // apply user options (@see skeleton/pub/index.php)
        if (isset($options['env'])) $this->env = $options['env'];
        if (isset($options['root'])) $this->root = $options['root'];
        if (isset($options['config'])) $this->applyConfig($options['config']);

        // check env
        if (empty($this->env)) {
            throw new AppException('Application env is not defined');
        }

        // security & performans checks
        $halt = $this->haltCheck();
        if ($halt != null) {
            $this->halt($halt[1], $halt[0]);
        }

        $this->applyDefaults();

        $this->request = new Request($this);
        $this->response = new Response($this);

        // @override
        set_global('app', $this);

        // create service
        $service = ServiceFactory::create($this);
        if ($service == null) {
            throw new AppException('Could not create service');
        }

        $this->startOutputBuffer();

        // here!!
        $this->events->fire('service.beforeRun');
        $output = $service->run();
        $this->events->fire('service.afterRun');

        $this->endOutputBuffer($output);
    }
148463
public function execute(array $args, array $options = [])
    {
        if (!isset($args[0])) {
            throw new \InvalidArgumentException('arg action must be input');
        }
        $action = explode('::', $args[0]);
        if (!class_exists($action[0])) {
            throw new \InvalidArgumentException('action not not found!');
        }

        ProcessManage::rmTask($action);
    }
657650
public function write($data, array $options = [])
    {
        $message_array = ['message' => $this->_serializeMessage($data)];
        if (array_key_exists('flags', $options)) {
            $message_array['flags'] = $options['flags'];
        }
        $this->call->startBatch([
            OP_SEND_MESSAGE => $message_array,
        ]);
    }
1151736
public function execute(array $args, array $options = [])
    {
        $this->bootstrap($args, $options);

        $version = isset($options['target']) ? $options['target'] : $options['t'];
        $removeAll = isset($options['remove-all']) ? $options['remove-all'] : $options['r'];

        if ($version && $removeAll){
            throw new \InvalidArgumentException('Cannot toggle a breakpoint and remove all breakpoints at the same time.');
        }

        // Remove all breakpoints
        if ($removeAll){
            $this->getManager()->removeBreakpoints();
        } else {
            // Toggle the breakpoint.
            $this->getManager()->toggleBreakpoint($version);
        }
    }
1019047
public function bootstrap(array $args, array $options = [])
    {
        if (false === class_exists('\Phinx\Config\Config')) {
            throw new \RuntimeException('please use `composer require linhecheng/cmlphp-ext-phinx` cmd to install phinx.');
        }

        if (!$this->getConfig()) {
            $this->loadConfig($options);
        }

        $this->loadManager($args, $options);
        // report the paths
        Output::writeln(
            'using migration path ' .
            Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $this->getConfig()->getMigrationPath()), Colour::GREEN)
        );
        Output::writeln(
            'using seed path ' .
            Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $this->getConfig()->getSeedPath()), Colour::GREEN)
        );

        $exportPath = false;
        if (isset($options['e'])) {
            $exportPath = $options['e'];
        } else if (isset($options['export'])) {
            $exportPath = $options['export'];
        }
        if ($exportPath) {
            is_dir($exportPath) || $exportPath = $this->getConfig()->getExportPath();
            is_dir($exportPath) || mkdir($exportPath, 0700, true);
            Output::writeln(
                'using export path:' .
                Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $exportPath), Colour::GREEN)
            );
            $merge = (isset($options['m']) || isset($options['merge'])) ? 'merge_export_' . date('Y-m-d-H-i-s') . '.sql' : false;
            $this->getManager()->getEnvironment()->setExportPath($exportPath, $merge);
        }

        $this->getConfig()->echoAdapterInfo();
    }
449744
public function execute(array $args, array $options = [])
    {
        $this->bootstrap($args, $options);

        $version = isset($options['target']) ? $options['target'] : $options['t'];
        $date = isset($options['date']) ? $options['date'] : $options['d'];
        $force = isset($options['force']) ? $options['force'] : $options['f'];

        // rollback the specified environment
        $start = microtime(true);
        if (null !== $date) {
            $this->getManager()->rollbackToDateTime(new \DateTime($date), $force);
        } else {
            $this->getManager()->rollback($version, $force);
        }
        $end = microtime(true);

        Output::writeln('');
        Output::writeln(Colour::colour('All Done. Took ', Colour::GREEN) . sprintf('%.4fs', $end - $start));
    }
731248
function addArgument($name, $options = array())
    {
        $arg = new Argument($name, $options);
        $this->args[] = $arg;

        return $this;
    }
316916
public static function sortArgs(array &$args) {
        ksort($args);
        foreach ($args as $key => $val) {
            if (is_array($val)) {
                ksort($val);
                $args [ $key ] = $val;
                self::sortArgs($val);
            }
        }
    }
999581
public function executeHello(array $args, array $options = array())
    {
        $name = 'unknown';
        if (empty($args)) {
            $dialog = new Dialog($this->console);
            $name = $dialog->ask('What is your name?', $name);
        } else {
            $name = $args[0];
        }
        $this->writeln(sprintf('hello %s!', $name));
    }