Cml\Console\Console::run PHP Метод

run() публичный Метод

运行命令
public run ( array $argv = null ) : mixed
$argv array
Результат mixed
    public function run(array $argv = null)
    {
        try {
            if ($argv === null) {
                $argv = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];
            }
            list($args, $options) = Input::parse($argv);
            $command = count($args) ? array_shift($args) : 'help';
            if (!isset($this->commands[$command])) {
                throw new \InvalidArgumentException("Command '{$command}' does not exist");
            }
            isset($options['no-ansi']) && Colour::setNoAnsi();
            if (isset($options['h']) || isset($options['help'])) {
                $help = new Help($this);
                $help->execute([$command]);
                exit(0);
            }
            $command = explode('::', $this->commands[$command]);
            return call_user_func_array([new $command[0]($this), isset($command[1]) ? $command[1] : 'execute'], [$args, $options]);
        } catch (\Exception $e) {
            Output::writeException($e);
            exit(1);
        }
    }