コード例 #1
0
ファイル: Dispatcher.php プロジェクト: wp-slab/slab-cli
 /**
  * Dispatch a request
  *
  * @param array Argv values
  * @return mixed Result
  **/
 public function dispatch(array $argv)
 {
     list($name, $arguments, $options) = $this->parser->parseInput($argv);
     if (empty($name)) {
         $name = 'list';
     }
     $command = $this->commands->getCommand($name);
     if (!$command) {
         throw new RuntimeException("Command not found: {$name}");
     }
     return $this->container->fireMethod($command, 'executeCommand', [$arguments, $options]);
 }
コード例 #2
0
 /**
  * Resolve a command
  *
  * @param class Command class
  * @return void
  **/
 public function resolve($str)
 {
     $pos = strpos($str, '@');
     if ($pos === false) {
         $class = $str;
         $method = null;
     } else {
         $class = substr($str, 0, $pos);
         $method = substr($str, $pos + 1);
     }
     $command = $this->container->make($class);
     if ($method) {
         $command->setExecuteMethod($method);
     }
     return $this->addCommand($command);
 }
コード例 #3
0
ファイル: Command.php プロジェクト: wp-slab/slab-cli
 /**
  * Execute the command with the provided input
  *
  * @param Slab\Core\ContainerInterface
  * @param array Arguments
  * @param array Options
  * @return int Exit status
  **/
 public function executeCommand(ContainerInterface $container, array $arguments, array $options)
 {
     // var_dump("Executing {$this->name}", $arguments, $options);
     // $this->setOutputter($container->make('Slab\Cli\Outputter'));
     return $container->fireMethod($this, $this->getExecuteMethod());
 }