コード例 #1
0
 /**
  * @param string          $command
  * @param array           $args
  * @param OutputInterface $output
  *
  * @return CreateArchiveCommand
  *
  * @throws \RuntimeException
  */
 public function runCommand($command, array $args, OutputInterface $output)
 {
     $input = new ArrayInput(array_merge($args, array('command' => $command)));
     $command = $this->getApplication()->find($command);
     $output->writeln(sprintf("Starting command: <info>%s</info>", $input->__toString()));
     $exception = $success = false;
     try {
         $success = $command->run($input, $output) === 0;
     } catch (\Exception $e) {
         $success = false;
         $exception = $e;
     }
     if (!$success) {
         $this->getApplication()->sendReport(Message::create($this->project, file_get_contents($this->log), 'ERROR'));
     }
     if (!$success) {
         throw new SuccessException(sprintf('<error>The command %s failed</error>', $command->getName()));
     }
     if ($exception) {
         throw $exception;
     }
     $output->writeln("end command");
     return $this;
 }