From d193a6aec41877fc180ae8a5128a75d58528192c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 22 Jul 2018 10:05:06 +0200 Subject: [PATCH] Give commands proper exit codes. --- app/Console/Commands/Import.php | 8 +++++--- app/Console/Commands/ScanAttachments.php | 3 ++- app/Console/Commands/UpgradeDatabase.php | 4 +++- app/Console/Commands/UpgradeFireflyInstructions.php | 3 ++- app/Console/Commands/UseEncryption.php | 3 ++- app/Console/Commands/VerifyDatabase.php | 6 ++++-- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php index 0446f6ccc5..5d6d853f59 100644 --- a/app/Console/Commands/Import.php +++ b/app/Console/Commands/Import.php @@ -59,7 +59,7 @@ class Import extends Command * * @throws FireflyException */ - public function handle(): void + public function handle(): int { Log::debug('Start start-import command'); $jobKey = $this->argument('key'); @@ -67,12 +67,12 @@ class Import extends Command if (null === $job) { $this->errorLine(sprintf('No job found with key "%s"', $jobKey)); - return; + return 1; } if (!$this->isValid($job)) { $this->errorLine('Job is not valid for some reason. Exit.'); - return; + return 1; } $this->infoLine(sprintf('Going to import job with key "%s" of type "%s"', $job->key, $job->file_type)); @@ -106,6 +106,8 @@ class Import extends Command } $this->infoLine(sprintf('The import has finished. %d transactions have been imported.', $count)); + + return 0; } /** diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/ScanAttachments.php index ac10dec27f..0a77363a0a 100644 --- a/app/Console/Commands/ScanAttachments.php +++ b/app/Console/Commands/ScanAttachments.php @@ -54,7 +54,7 @@ class ScanAttachments extends Command /** * Execute the console command. */ - public function handle(): void + public function handle(): int { $attachments = Attachment::get(); $disk = Storage::disk('upload'); @@ -82,5 +82,6 @@ class ScanAttachments extends Command $attachment->save(); $this->line(sprintf('Fixed attachment #%d', $attachment->id)); } + return 0; } } diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php index 5c328ac60f..927630bc50 100644 --- a/app/Console/Commands/UpgradeDatabase.php +++ b/app/Console/Commands/UpgradeDatabase.php @@ -82,7 +82,7 @@ class UpgradeDatabase extends Command /** * Execute the console command. */ - public function handle(): void + public function handle(): int { $this->setTransactionIdentifier(); $this->updateAccountCurrencies(); @@ -96,6 +96,8 @@ class UpgradeDatabase extends Command $this->migrateBillsToRules(); $this->info('Firefly III database is up to date.'); + + return 0; } /** diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index eae3998a22..54695221c4 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -46,7 +46,7 @@ class UpgradeFireflyInstructions extends Command /** * Execute the console command. */ - public function handle(): void + public function handle(): int { if ('update' === $this->argument('task')) { $this->updateInstructions(); @@ -54,6 +54,7 @@ class UpgradeFireflyInstructions extends Command if ('install' === $this->argument('task')) { $this->installInstructions(); } + return 0; } /** diff --git a/app/Console/Commands/UseEncryption.php b/app/Console/Commands/UseEncryption.php index df38fff556..bfc04db91c 100644 --- a/app/Console/Commands/UseEncryption.php +++ b/app/Console/Commands/UseEncryption.php @@ -47,7 +47,7 @@ class UseEncryption extends Command /** * Execute the console command. */ - public function handle(): void + public function handle(): int { if (true === config('firefly.encryption')) { $this->info('Firefly III configuration calls for encrypted data.'); @@ -62,6 +62,7 @@ class UseEncryption extends Command $this->handleObjects('Category', 'name', 'encrypted'); $this->handleObjects('PiggyBank', 'name', 'encrypted'); $this->handleObjects('TransactionJournal', 'description', 'encrypted'); + return 0; } /** diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php index dc43c373bb..88635664ae 100644 --- a/app/Console/Commands/VerifyDatabase.php +++ b/app/Console/Commands/VerifyDatabase.php @@ -69,11 +69,11 @@ class VerifyDatabase extends Command /** * Execute the console command. */ - public function handle(): void + public function handle(): int { // if table does not exist, return false if (!Schema::hasTable('users')) { - return; + return 1; } $this->reportEmptyBudgets(); @@ -94,6 +94,8 @@ class VerifyDatabase extends Command $this->fixDoubleAmounts(); $this->fixBadMeta(); $this->removeBills(); + + return 0; } /**