From 6bb8ec3da908692d83eaa3d5de8faee16194df7a Mon Sep 17 00:00:00 2001 From: Damien Gavard Date: Tue, 16 Aug 2016 11:31:38 +0200 Subject: [PATCH] Make command more verbose --- src/Command/ProtectAllBuildsCommand.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Command/ProtectAllBuildsCommand.php b/src/Command/ProtectAllBuildsCommand.php index 5b5c20d..e54d5ea 100644 --- a/src/Command/ProtectAllBuildsCommand.php +++ b/src/Command/ProtectAllBuildsCommand.php @@ -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; @@ -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)); } }