/**
* {@inheritdoc}
*
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$buildId = $this->stdIn->getArgument('build');
$client = new Client(['base_uri' => 'https://api.travis-ci.org/', 'cookies' => true, 'headers' => ['User-Agent' => 'DrupalOrgCli/0.0.1', 'Accept' => 'application/json', 'Accept-Encoding' => '*']]);
$build = $this->getBuild($client, $buildId);
$this->stdOut->writeln("<comment>Watching build {$buildId}</comment>");
$progress = new ProgressBar($this->stdOut);
$progress->start();
if ($build->state == 'finished') {
$progress->advance();
} else {
while ($build->state != 'finished') {
$progress->advance();
sleep(60);
$build = $this->getBuild($client, $buildId);
}
}
$progress->finish();
$this->sendNotification('TravisCI', "TravisCI build {$buildId} completed");
$this->stdOut->writeln('');
$table = new Table($this->stdOut);
$table->setHeaders(['ID', 'Message', 'Result']);
if ($build->result == 0) {
$style = 'info';
$result = 'pass';
} elseif ($build->result == 1) {
$style = 'error';
$result = 'fail';
} else {
$style = 'comment';
$result = 'pending';
}
$table->addRow([$buildId, $build->message, "<{$style}>" . $result . "</{$style}>"]);
$table->render();
}