コード例 #1
0
 /**
  * Constructor.
  *
  * @param Definition|null $definition
  * @param array|null      $arg
  */
 public function __construct(array $arg = null, Definition $definition = null)
 {
     $argv = $arg ?: $_SERVER['argv'];
     array_shift($argv);
     $this->tokens = $argv;
     parent::__construct($definition);
 }
コード例 #2
0
 /**
  * Run console.
  *
  * @param AbstractInput $input
  */
 public function run(AbstractInput $input)
 {
     $this->output = $this->output ?: new Output();
     $input->bind($this->definition);
     if (true === $input->option->get('no-ansi')) {
         $this->output->setEnableAnsi(false);
     }
     if (true === $input->option->get('help')) {
         $this->application->writeHelp($this, $input->option->all());
     } else {
         $input->validate();
         $args = func_get_args();
         array_shift($args);
         call_user_func_array(array($this, 'execute'), array_merge(array($input, $this->output), $args));
     }
 }
コード例 #3
0
 /**
  * Run application.
  *
  * @param AbstractInput $input
  */
 public function run(AbstractInput $input)
 {
     try {
         if (null !== ($command = $input->getFirstArgument())) {
             $console = $this->getConsole($command);
         } else {
             $console = $this->getConsole('list');
         }
         try {
             if (null === $this->executor) {
                 $console->run($input);
             } else {
                 call_user_func($this->executor, $input, $console);
             }
         } catch (Exception $e) {
             if ($e instanceof ShowHelpException) {
                 $this->writeHelp($console);
             } else {
                 throw $e;
             }
         }
     } catch (Exception $e) {
         $this->writeException($e, new Output());
     }
 }