Skip to content

Commit

Permalink
Make command more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
dagio committed Aug 16, 2016
1 parent c4a2af3 commit 6bb8ec3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Command/ProtectAllBuildsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use DAG\Appetize\Deploy\API\Api;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,10 +22,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
$api = new Api($input->getArgument('token'));
$builds = $api->fetchAll();

$progress = new ProgressBar($output, count($builds));
$buildChangedCount = 0;

foreach ($builds as $build) {
$api->protectBuild($build['publicKey']);
if (!isset($build['protectedByAccount']) || !$build['protectedByAccount']) {
$api->protectBuild($build['publicKey']);
$buildChangedCount++;
}
$progress->advance();
$progress->display();
}

return;
$output->writeln("");

$output->writeln(sprintf('%d builds were changed', $buildChangedCount));
}
}

0 comments on commit 6bb8ec3

Please sign in to comment.