From 256f70388abd6c79fc7db95c8714ebb0bbb14ad1 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Sun, 20 Nov 2022 11:31:31 -0100 Subject: [PATCH] command returns int Signed-off-by: Maxence Lange --- lib/Command/AccountCreate.php | 4 +++- lib/Command/AccountFollowing.php | 4 +++- lib/Command/CacheRefresh.php | 4 +++- lib/Command/CheckInstall.php | 8 +++++--- lib/Command/Fediverse.php | 6 ++++-- lib/Command/MigrateAlpha3.php | 10 ++++++---- lib/Command/NoteBoost.php | 4 +++- lib/Command/NoteCreate.php | 4 +++- lib/Command/NoteLike.php | 4 +++- lib/Command/QueueProcess.php | 3 ++- lib/Command/QueueStatus.php | 4 +++- lib/Command/Reset.php | 14 ++++++++------ lib/Command/StreamDetails.php | 6 ++++-- 13 files changed, 50 insertions(+), 25 deletions(-) diff --git a/lib/Command/AccountCreate.php b/lib/Command/AccountCreate.php index 12b05e1a..d08aa63f 100644 --- a/lib/Command/AccountCreate.php +++ b/lib/Command/AccountCreate.php @@ -75,7 +75,7 @@ class AccountCreate extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('userId'); if (($handle = $input->getOption('handle')) === null) { @@ -87,5 +87,7 @@ class AccountCreate extends Base { } $this->accountService->createActor($userId, $handle); + + return 0; } } diff --git a/lib/Command/AccountFollowing.php b/lib/Command/AccountFollowing.php index 66fbb4cf..84563572 100644 --- a/lib/Command/AccountFollowing.php +++ b/lib/Command/AccountFollowing.php @@ -76,7 +76,7 @@ class AccountFollowing extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('userId'); $account = $input->getArgument('account'); @@ -91,5 +91,7 @@ class AccountFollowing extends Base { } else { $this->followService->followAccount($actor, $account); } + + return 0; } } diff --git a/lib/Command/CacheRefresh.php b/lib/Command/CacheRefresh.php index 2f1e45a4..5d39f373 100644 --- a/lib/Command/CacheRefresh.php +++ b/lib/Command/CacheRefresh.php @@ -67,7 +67,7 @@ class CacheRefresh extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $result = $this->accountService->blindKeyRotation(); $output->writeLn($result . ' key pairs refreshed'); @@ -85,5 +85,7 @@ class CacheRefresh extends Base { $result = $this->hashtagService->manageHashtags(); $output->writeLn($result . ' hashtags updated'); + + return 0; } } diff --git a/lib/Command/CheckInstall.php b/lib/Command/CheckInstall.php index e0a3712d..d3396455 100644 --- a/lib/Command/CheckInstall.php +++ b/lib/Command/CheckInstall.php @@ -31,7 +31,6 @@ declare(strict_types=1); namespace OCA\Social\Command; -use OCA\Social\Tools\Traits\TArrayTools; use Exception; use OC\Core\Command\Base; use OCA\Social\Db\StreamDestRequest; @@ -42,6 +41,7 @@ use OCA\Social\Service\CheckService; use OCA\Social\Service\ConfigService; use OCA\Social\Service\MiscService; use OCA\Social\Service\PushService; +use OCA\Social\Tools\Traits\TArrayTools; use OCP\IUserManager; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; @@ -97,9 +97,9 @@ class CheckInstall extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->askRegenerateIndex($input, $output)) { - return; + return 0; } // if ($this->checkPushApp($input, $output)) { @@ -114,6 +114,8 @@ class CheckInstall extends Base { $output->writeln(''); $output->writeln('- Your current configuration: '); $output->writeln(json_encode($this->configService->getConfig(), JSON_PRETTY_PRINT)); + + return 0; } /** diff --git a/lib/Command/Fediverse.php b/lib/Command/Fediverse.php index f4c11956..e2801bbd 100644 --- a/lib/Command/Fediverse.php +++ b/lib/Command/Fediverse.php @@ -69,11 +69,11 @@ class Fediverse extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->output = $output; if ($this->typeAccess($input->getOption('type'))) { - return; + return 0; } $this->output->writeln( @@ -108,6 +108,8 @@ class Fediverse extends Base { default: throw new Exception('specify action: add, remove, list, reset'); } + + return 0; } /** diff --git a/lib/Command/MigrateAlpha3.php b/lib/Command/MigrateAlpha3.php index e59e9a99..05774920 100644 --- a/lib/Command/MigrateAlpha3.php +++ b/lib/Command/MigrateAlpha3.php @@ -130,7 +130,7 @@ class MigrateAlpha3 extends Base { /** * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $tables = $this->checkTables(); if ($input->getOption('force-remove-old-tables')) { @@ -138,13 +138,13 @@ class MigrateAlpha3 extends Base { $this->dropTable($table); } - return; + return 0; } if (empty($tables)) { $output->writeln('Nothing to migrate.'); - return; + return 0; } $defTables = ''; @@ -157,7 +157,7 @@ class MigrateAlpha3 extends Base { ); if (!$this->confirmExecute($input, $output)) { - return; + return 0; } $this->done = []; @@ -166,6 +166,8 @@ class MigrateAlpha3 extends Base { if ($input->getOption('remove-migrated-tables')) { $this->dropDeprecatedTables($input, $output); } + + return 0; } diff --git a/lib/Command/NoteBoost.php b/lib/Command/NoteBoost.php index 91c83983..67a5c0cc 100644 --- a/lib/Command/NoteBoost.php +++ b/lib/Command/NoteBoost.php @@ -85,7 +85,7 @@ class NoteBoost extends Base { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('user_id'); $noteId = $input->getArgument('note_id'); @@ -101,5 +101,7 @@ class NoteBoost extends Base { echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"; echo 'token: ' . $token . "\n"; + + return 0; } } diff --git a/lib/Command/NoteCreate.php b/lib/Command/NoteCreate.php index b0e990b9..d5ea7827 100644 --- a/lib/Command/NoteCreate.php +++ b/lib/Command/NoteCreate.php @@ -121,7 +121,7 @@ class NoteCreate extends Base { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('userid'); $content = $input->getArgument('content'); $to = $input->getOption('to'); @@ -142,5 +142,7 @@ class NoteCreate extends Base { echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"; echo 'token: ' . $token . "\n"; + + return 0; } } diff --git a/lib/Command/NoteLike.php b/lib/Command/NoteLike.php index 63364298..6d01fe09 100644 --- a/lib/Command/NoteLike.php +++ b/lib/Command/NoteLike.php @@ -97,7 +97,7 @@ class NoteLike extends Base { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('user_id'); $noteId = $input->getArgument('note_id'); @@ -113,5 +113,7 @@ class NoteLike extends Base { echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"; echo 'token: ' . $token . "\n"; + + return 0; } } diff --git a/lib/Command/QueueProcess.php b/lib/Command/QueueProcess.php index fb9d6180..6e1e51d4 100644 --- a/lib/Command/QueueProcess.php +++ b/lib/Command/QueueProcess.php @@ -87,12 +87,13 @@ class QueueProcess extends Base { * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeLn('processing requests queue'); $this->processRequestQueue($output); $output->writeLn('processing stream queue'); $this->processStreamQueue($output); + return 0; } diff --git a/lib/Command/QueueStatus.php b/lib/Command/QueueStatus.php index 67e256be..2e2bbbc3 100644 --- a/lib/Command/QueueStatus.php +++ b/lib/Command/QueueStatus.php @@ -85,7 +85,7 @@ class QueueStatus extends Base { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $token = $input->getOption('token'); if ($token === null) { @@ -97,5 +97,7 @@ class QueueStatus extends Base { foreach ($requests as $request) { $output->writeLn(json_encode($request)); } + + return 0; } } diff --git a/lib/Command/Reset.php b/lib/Command/Reset.php index e01138d5..b96e2307 100644 --- a/lib/Command/Reset.php +++ b/lib/Command/Reset.php @@ -91,7 +91,7 @@ class Reset extends Base { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $helper = $this->getHelper('question'); $output->writeln( 'Beware, this operation will delete all content from the Social App.' @@ -102,7 +102,7 @@ class Reset extends Base { ); if (!$helper->ask($input, $output, $question)) { - return; + return 0; } $question = new ConfirmationQuestion( @@ -110,7 +110,7 @@ class Reset extends Base { '/^(y|Y)/i' ); if (!$helper->ask($input, $output, $question)) { - return; + return 0; } @@ -124,7 +124,7 @@ class Reset extends Base { $output->writeln('' . $e->getMessage() . ''); } - return; + return 0; } @@ -136,7 +136,7 @@ class Reset extends Base { } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); - return; + return 0; } $this->checkService->checkInstallationStatus(true); @@ -152,13 +152,15 @@ class Reset extends Base { $newCloudAddress = $helper->ask($input, $output, $question); if ($newCloudAddress === $cloudAddress) { - return; + return 0; } $this->configService->setCloudUrl($newCloudAddress); $output->writeln(''); $output->writeln('New address: ' . $newCloudAddress . ''); + + return 0; } diff --git a/lib/Command/StreamDetails.php b/lib/Command/StreamDetails.php index 94dce92f..a0dab3af 100644 --- a/lib/Command/StreamDetails.php +++ b/lib/Command/StreamDetails.php @@ -92,7 +92,7 @@ class StreamDetails extends ExtendedBase { * * @throws Exception */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $output = new ConsoleOutput(); $this->output = $output->section(); @@ -110,7 +110,7 @@ class StreamDetails extends ExtendedBase { if ($this->asJson) { $this->output->writeln(json_encode($details, JSON_PRETTY_PRINT)); - return; + return 0; } $this->outputStream($stream); @@ -133,5 +133,7 @@ class StreamDetails extends ExtendedBase { $this->output->writeln('* Direct: ' . json_encode($direct, JSON_PRETTY_PRINT)); $this->output->writeln('* Public: ' . ($details->isPublic() ? 'true' : 'false')); $this->output->writeln('* Federated: ' . ($details->isFederated() ? 'true' : 'false')); + + return 0; } }