Calls to command action.
@since 1.0.0

@param array $args Action arguments.
485983
public function call($args = [])
    {
        if (count($args) == 0 || empty($args[2]))
            throw new NoticeException('Command "'.$this->key.'": Expecting a hook (action|filter|shortcode).');

        $object = explode(':', $args[2]);

        // Validations
        if (!in_array($object[0], ['action', 'filter', 'shortcode']))
            throw new NoticeException('Command "'.$this->key.'": Invalid hook. Expecting action or filter.');

        if (!isset($object[1]))
            throw new NoticeException('Command "'.$this->key.'": Expecting a hook name. i.e. add:init (where "init" would be the hook name).');

        if (count($args) == 3)
            $args[] = 'AppController@'.$object[1];

        // View or controller
        $vc = explode('@', $args[3]);
        if (count($vc) == 1) {
            $vc[] = preg_replace('/\-\./', '_', $object[1]);
            $args[3] .= '@'.$vc[1];
        }
        switch ($vc[0]) {
            case 'view':
                $this->createView($vc[1]);
                break;
            default:
                $this->createController($vc[0]);
                $this->createControllerMethod(
                    $vc[0],
                    $vc[1],
                    $this->getHookParams($object[1]),
                    (ucfirst($object[0]).' "'.$object[1].'"'."\n".'     * Wordpress hook')
                );
                break;
        }

        // Add hook to bridge
        $builder = Builder::parser($this->rootPath.'/app/Main.php');
        $builder->addVisitor(new AddMethodCallVisitor($this->getHookScope($object[1]), 'add_'.$object[0], [$object[1], $args[3]]));
        $builder->build();
    }
693856
public function run($argv) {

        if (count($argv) == 1) {
            $this->help();
            return;
        }
        array_shift($argv);
        $command = array_shift($argv);
        $params = [];
        for ($i = 0; $i < count($argv); $i += 2) {
            $key = $argv[ $i ];
            $value = $argv[ $i + 1 ];
            if ($value === null || strpos('-', $value) === 0) {
                $params[ substr($key, 1) ] = true;
                $i--;
                continue;
            }
            if ($value == 'true') {
                $value = true;
            }
            if ($value == 'false') {
                $value = false;
            }
            $params[ substr($key, 1) ] = $value;
        }
        if (strpos($command, '-') === 0) {
            $this->help();
            return;
        }
        /* @var $command_obj Command */
        $command_obj = $this->defaultCommand[ $command ];
        if (key_exists('h', $params)) {
            $command_obj->help();
            return;
        }
        $this->invoke($command_obj, $params);
    }
309506
private function cmdCheck($args)
    {
        $cmd = new CheckCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
636780
public static function run()
    {
        if ($_SERVER['argc'] < 2) {
            self::helpAction();
            exit();
        }
        $method = $_SERVER['argv'][1] . 'Action';
        if (method_exists(static::getCurrentClass(), $method)) {
            $params = $_SERVER['argv'];
            array_shift($params);
            array_shift($params);
            call_user_func_array(array(static::getCurrentClass(), $method), $params);
        } else {
            self::displayError("command unknown", true);
        }
    }
1283985
public function main(array $args = array()) {
        if ($this->_isHelpRequested($args)) {
            $this->_displayHelp();
            return true;
        }

        if (!$this->setArgs($args)) {
            return false;
        }
        $this->setFilter(new Garp_Cli_Command_Spawn_Filter($args));
        $this->setFeedback(new Garp_Cli_Command_Spawn_Feedback($args));
        $this->setModelSet($this->_initModelSet());

        $feedback = $this->getFeedback();
        $feedback->shouldSpawn() ? $this->_spawn() :
            $this->_showJsBaseModel($args[Garp_Cli_Command_Spawn_Feedback::JS_BASE_MODEL_COMMAND]);
        return true;
    }
757892
public function activate( $args, $assoc_args ) {
		\WP_CLI::warning( 'This command is deprecated. use wp site switch-language instead' );

		list( $language_code ) = $args;

		$this->activate_language( $language_code );
	}
1215204
public static function route(string $command, array $args) : void {
        $object = new static('test');
        echo "\n";
        if (method_exists(static::class, $command)) {
            $response = call_user_func_array([$object, $command], $args);
            if ($response === NULL)
                echo "SUCCESS";
            else if ($response === FALSE)
                echo "FALSE";
            else if ($response === TRUE)
                echo "TRUE";
            else {
                if (is_string($response))
                    echo $response;
                else print_r($response);
            }
        } else echo "No such method available";
        echo "\n\n";
    }
282891
protected function handle($name, array $args = [])
    {
        if (isset($this->handlers[$name]) && is_callable($this->handlers[$name])) {
            array_unshift($args, $this);
            call_user_func_array($this->handlers[$name], $args);
        }
    }
1359861
public function execute($arguments)
  {
    // Validate on given command.
    if (!isset($this->options['cmd'])) {
      throw new \Exception(sprintf('No command given for "%s"', $this->name));
      exit(1);
    }

    // If a explicit working directory is specifified, we change to that to call
    // the command.
    $workingDir = $this->getWorkingDir();
    if (isset($workingDir)) {
      chdir($workingDir);
    }

    // Execute the command.
    $status = NULL;
    $cmd = $this->options['cmd'];

    // If a explicit command dir is given, we use an absolute path to the command.
    $cmdDir = $this->getCmdDir();
    if (isset($cmdDir)) {
      $cmd = $cmdDir . '/' . $cmd;
    }
    $cmd = escapeshellcmd($cmd);

    // Add passed arguments to the command.
    foreach ($arguments as $arg) {
      $cmd .= ' ' . escapeshellarg($arg);
    }
    passthru($cmd, $status);
    exit($status);
  }
974742
public function call($args = [])
    {
        if (count($args) == 0 || empty($args[2]))
            throw new NoticeException('Command "'.$this->key.'": Expecting an object to create (model|view|controller).');

        $object = explode(':', $args[2]);

        switch ($object[0]) {
            case 'view':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": View key name is missing.');
                $this->createView($object[1], $args);
                break;
            case 'controller':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Controller definition is missing.');
                $controller = explode('@', $object[1]);
                $this->createController($controller[0], $args);
                // Create method
                if (count($controller) > 1)
                    $this->createControllerMethod($controller[0], $controller[1]);
                break;
            case 'model':
            case 'postmodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1]);
                // Add type
                if (isset($args[3]))
                    $this->createModelProperty($object[1], 'type', $args[3]);
                break;
            case 'optionmodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'OptionModel');
                // Add id
                $this->createModelProperty($object[1], 'id', isset($args[3]) ? $args[3] : uniqid());
                break;
            case 'usermodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'UserModel');
                break;
            case 'categorymodel':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Model definition is missing.');
                $this->createModel($object[1], 'CategoryModel');
                break;
        }
    }
1347574
public function call($args = [])
    {
        if (count($args) == 0 || empty($args[2]))
            throw new NoticeException('Command "'.$this->key.'": Expecting an object to resigter (widget|type).');

        $object = explode(':', $args[2]);

        switch ($object[0]) {
            case 'widget':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a widget class name.');
                $this->registerWidget($object[1], $args);
                break;
            case 'type':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a post type. I.e. "ayuco register type:book" (where "book" would be the type)');
                // Prepare
                $model = !isset($args[3]) || empty($args[3]) ? ucfirst($object[1]) : $args[3];
                $controller = !isset($args[4]) || empty($args[4]) ? null : $args[4];
                // Create controller
                $this->createModel($model);
                // Set properties
                $this->createModelProperty($model, 'type', $object[1]);
                $this->createModelProperty($model, 'aliases', []);
                if ($controller) {
                    $this->createModelProperty($model, 'registry_controller', $controller);
                    $this->createModelProperty($model, 'registry_metabox', ['title'=>'Meta fields','context'=>'normal','priority'=>'default']);
                    // Create controller
                    $this->createModelController($controller);
                    $this->createControllerProperty($controller, 'model', $this->config['namespace'].'\\Models\\'.$model);
                    // Create view
                    $this->createView('admin.metaboxes.'.$object[1].'.meta', 'metabox.php');
                }
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_model', [$model]));
                $builder->build();
                break;
            case 'model':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a model name.');
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_model', [$object[1]]));
                $builder->build();
                // Print end
                $this->_print('Model registered!');
                $this->_lineBreak();
                break;
            case 'asset':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting an asset relative path.');
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_asset', [$object[1]]));
                $builder->build();
                // Print end
                $this->_print('Asset registered!');
                $this->_lineBreak();
                break;
        }
    }
695458
private function runAction($action, $args)
    {
        $function = $action['function'];
        $argsNumber = $action['arguments'];

        $class = (isset($function[0])) ? $function[0] : false;
        $method = (isset($function[1])) ? $function[1] : false;

        $args = $this->getArguments($argsNumber, $args);

        if (! ($class && $method) && function_exists($function)) {
            return call_user_func($function, $args);
        } elseif ($obj = call_user_func([$class, $this->singleton])) {
            if ($obj !== false) {
                return call_user_func_array([$obj, $method], $args);
            }
        } elseif (class_exists($class)) {
            $instance = new $class;

            return call_user_func_array([$instance, $method], $args);
        }
    }
87052
public function run($args)
  {
    $this->args = $args;
    if(!isset($this->args['commands'][1])){
      print PHP_EOL.self::USAGE;
      return;
    }
    $this->name = trim($this->args['commands'][1]);

    $path = '.'.DIRECTORY_SEPARATOR;
    $this->path = realpath($path).DIRECTORY_SEPARATOR;
    if(is_dir($this->path.$this->name)){
       print 'Directory already exists!'.PHP_EOL;
       return;
    }
    $this->io = new \myo\filaments\io;
    $this->file = $this->root.DIRECTORY_SEPARATOR.'filaments'.DIRECTORY_SEPARATOR.'repo'.DIRECTORY_SEPARATOR.'master.zip';

    if(isset($this->args['options']['app-path'])){
      $this->path = rtrim($this->args['options']['app-path'],'/\\').DIRECTORY_SEPARATOR;
    }

    $zip = $this->io->archiveOpen($this->file);

    if(stream_resolve_include_path($this->file) && !in_array('c',$this->args['flags'])){

      print PHP_EOL.'The current version is: '.$zip->getArchiveComment().PHP_EOL;
      print PHP_EOL.'Do you want to check the HEAD revision on Github [no]?(yes/no)';

      $answer = $this->io->getInput();

      if($answer == 'yes'){
        $this->checkGithub($zip);
      }else{
        $this->deploy($zip);
      }

    }else{
      print PHP_EOL.'No archive found!'.PHP_EOL.PHP_EOL.'Downloading one from Github (Ctrl+c to abort)'.PHP_EOL;
      $this->checkGithub($zip);
    }

  }
837942
public function run(...$args): void
    {
        $container = $this->getContainer();
        $instance = $container->get($this->classIdentifier);

        $instance->{$this->callbackMethod}(...$args);
    }
776922
protected function invokeCommands(array $commands) {
    foreach ($commands as $key => $value) {
      if (is_numeric($key)) {
        $command = $value;
        $args = [];
      }
      else {
        $command = $key;
        $args = $value;
      }
      $this->invokeCommand($command, $args);
    }
  }
761095
protected function callAllListeners($args = [])
    {
        $args = (array) $args;
        array_map(function ($event) use ($args) {
            $this->callListeners($event, $args);
        }, array_keys($this->listeners));
    }
744749
public void run(String[] args) {
        String context = args.length > 0 ? args[0] : "";
        String action = args.length > 1 ? args[1] : "";
        String option = args.length > 2 ? args[2] : "";

        switch (context) {
            case "server":
                server(action, option);
                break;
            case "version":
                version();
                break;
            default:
                help();
        }
    }