* @package PHPCI * @subpackage Console */ class RunCommand extends Command { protected function configure() { $this ->setName('phpci:run-builds') ->setDescription('Run all pending PHPCI builds.'); } /** * Pulls all pending builds from the database and runs them. */ protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $store = Factory::getStore('Build'); $result = $store->getByStatus(0); $builds = 0; foreach ($result['items'] as $build) { $builds++; $build = BuildFactory::getBuild($build); if ($input->getOption('verbose')) { $builder = new Builder($build, function ($log) { $this->output->writeln($log); }); } else { $builder = new Builder($build, function () { // Empty stub function. }); } $builder->execute(); } return $builds; } }