summaryrefslogtreecommitdiffstats
path: root/lib/Command/Updater/AfterUpdate.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Command/Updater/AfterUpdate.php')
-rw-r--r--lib/Command/Updater/AfterUpdate.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Command/Updater/AfterUpdate.php b/lib/Command/Updater/AfterUpdate.php
index bedc8c9ff..f9e5671f0 100644
--- a/lib/Command/Updater/AfterUpdate.php
+++ b/lib/Command/Updater/AfterUpdate.php
@@ -15,6 +15,7 @@ use OCA\News\Service\ItemServiceV2;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class AfterUpdate extends Command
@@ -42,14 +43,26 @@ class AfterUpdate extends Command
{
$this->setName('news:updater:after-update')
->setDescription('removes old read articles which are not starred')
- ->addArgument('purge_count', InputArgument::OPTIONAL, 'The amount of items to purge');
+ ->addArgument('purge-count', InputArgument::OPTIONAL, 'The amount of items to purge')
+ ->addOption('purge-unread', null, InputOption::VALUE_NONE, 'If unread items should be purged');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
- $count = (int) $input->getArgument('purge_count');
+ $count = $input->getArgument('purge-count');
+ $removeUnread = $input->getOption('purge-unread');
- $output->writeln($this->itemService->purgeOverThreshold($count));
+ if ($count !== null) {
+ $count = intval($count);
+ }
+
+ $result = $this->itemService->purgeOverThreshold($count, $removeUnread);
+ if ($result === null) {
+ $output->writeln('No cleanup needed', $output::VERBOSITY_VERBOSE);
+ return 0;
+ }
+
+ $output->writeln('Removed ' . $result . ' item(s)', $output::VERBOSITY_VERBOSE);
return 0;
}