Add summary with amount of updates

Signed-off-by: Tobia De Koninck <LEDfan@users.noreply.github.com>
This commit is contained in:
Tobia De Koninck 2018-08-27 12:17:22 +02:00
parent e87caedf7e
commit d492b2c399
1 changed files with 13 additions and 0 deletions

View File

@ -62,10 +62,13 @@ class Check extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
$updatesAvailableCount = 0;
// Server
$r = $this->updateChecker->getUpdateState();
if (isset($r['updateAvailable']) && $r['updateAvailable']) {
$output->writeln($r['updateVersion'] . ' is available. Get more information on how to update at '. $r['updateLink'] . '.');
$updatesAvailableCount += 1;
}
@ -75,9 +78,19 @@ class Check extends Command {
$update = $this->installer->isUpdateAvailable($app);
if ($update !== false) {
$output->writeln('Update for ' . $app . ' to version ' . $update . ' is available.');
$updatesAvailableCount += 1;
}
}
// Report summary
if ($updatesAvailableCount === 0) {
$output->writeln('<info>Everything up to date</info>');
} else if ($updatesAvailableCount === 1) {
$output->writeln('<comment>1 update available</comment>');
} else {
$output->writeln('<comment>' . $updatesAvailableCount . ' updates available</comment>');
}
return 0;
}
}