diff --git a/REUSE.toml b/REUSE.toml index d76c9152..1921fb3b 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -17,6 +17,12 @@ precedence = "aggregate" SPDX-FileCopyrightText = "2023 Nextcloud GmbH and Nextcloud contributors" SPDX-License-Identifier = "AGPL-3.0-or-later" +[[annotations]] +path = ["tests/stubs/oc_core_command_base.php"] +precedence = "aggregate" +SPDX-FileCopyrightText = "2026 Nextcloud GmbH and Nextcloud contributors" +SPDX-License-Identifier = "AGPL-3.0-or-later" + [[annotations]] path = ["img/app.svg", "img/app-dark.svg"] precedence = "aggregate" diff --git a/lib/Command/Log.php b/lib/Command/Log.php index 58ecb29d..7892f1af 100644 --- a/lib/Command/Log.php +++ b/lib/Command/Log.php @@ -8,14 +8,14 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; -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 Log extends Command { +class Log extends Base { private $queue; public function __construct( diff --git a/lib/Command/Metrics.php b/lib/Command/Metrics.php index 5d808c89..5697db78 100644 --- a/lib/Command/Metrics.php +++ b/lib/Command/Metrics.php @@ -8,13 +8,13 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; use OCA\NotifyPush\Queue\RedisQueue; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Metrics extends Command { +class Metrics extends Base { private $queue; public function __construct( @@ -51,6 +51,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Invalid metrics received from push server'); return 1; } + + // Output in the requested format if different from plain + if ($input->getOption('output') !== self::OUTPUT_FORMAT_PLAIN) { + $this->writeArrayInOutputFormat($input, $output, $metrics); + return 0; + } + $output->writeln('Active connection count: ' . $metrics['active_connection_count']); $output->writeln('Active user count: ' . $metrics['active_user_count']); $output->writeln('Total connection count: ' . $metrics['total_connection_count']); diff --git a/lib/Command/Reset.php b/lib/Command/Reset.php index 903c0280..6e7c6f54 100644 --- a/lib/Command/Reset.php +++ b/lib/Command/Reset.php @@ -8,12 +8,12 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\Queue\IQueue; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Reset extends Command { +class Reset extends Base { private $queue; public function __construct( diff --git a/lib/Command/SelfTest.php b/lib/Command/SelfTest.php index 7c9d9ac6..7e093ca6 100644 --- a/lib/Command/SelfTest.php +++ b/lib/Command/SelfTest.php @@ -8,12 +8,12 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCP\IConfig; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SelfTest extends Command { +class SelfTest extends Base { private $test; private $config; diff --git a/lib/Command/Setup.php b/lib/Command/Setup.php index 66a69f57..501bf55a 100644 --- a/lib/Command/Setup.php +++ b/lib/Command/Setup.php @@ -8,14 +8,14 @@ namespace OCA\NotifyPush\Command; +use OC\Core\Command\Base; use OCA\NotifyPush\SetupWizard; use OCP\IConfig; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Setup extends Command { +class Setup extends Base { private $test; private $config; private $setupWizard; diff --git a/psalm.xml b/psalm.xml index 7a444190..85a638b5 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,6 +21,7 @@ + diff --git a/tests/stubs/oc_core_command_base.php b/tests/stubs/oc_core_command_base.php new file mode 100644 index 00000000..5e9f9a01 --- /dev/null +++ b/tests/stubs/oc_core_command_base.php @@ -0,0 +1,33 @@ +