From d492b2c3998ddf0395acaac2572097447eb01586 Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Mon, 27 Aug 2018 12:17:22 +0200 Subject: [PATCH] Add summary with amount of updates Signed-off-by: Tobia De Koninck --- apps/updatenotification/lib/Command/Check.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/updatenotification/lib/Command/Check.php b/apps/updatenotification/lib/Command/Check.php index c6109e44e6a..f363832873b 100644 --- a/apps/updatenotification/lib/Command/Check.php +++ b/apps/updatenotification/lib/Command/Check.php @@ -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('Everything up to date'); + } else if ($updatesAvailableCount === 1) { + $output->writeln('1 update available'); + } else { + $output->writeln('' . $updatesAvailableCount . ' updates available'); + } + return 0; } }