From 4ccbf86589dd7717cdd63fecefc446725b295c32 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 17 May 2022 16:51:34 +0300 Subject: [PATCH] exit status usage --- application/Espo/Core/Console/Commands/Extension.php | 11 ++++++++++- application/Espo/Core/Console/Commands/RunJob.php | 1 + .../Espo/Core/Console/Commands/SetPassword.php | 12 ++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/application/Espo/Core/Console/Commands/Extension.php b/application/Espo/Core/Console/Commands/Extension.php index c2e9990776..3286ee1d7a 100644 --- a/application/Espo/Core/Console/Commands/Extension.php +++ b/application/Espo/Core/Console/Commands/Extension.php @@ -70,6 +70,7 @@ class Extension implements Command if (!$name && !$id) { $io->writeLine("Can't uninstall. Specify --name=\"Extension Name\"."); + $io->setExitStatus(1); return; } @@ -112,6 +113,7 @@ class Extension implements Command if (!$this->fileManager->isFile($file)) { $io->writeLine("File does not exist."); + $io->setExitStatus(1); return; } @@ -125,6 +127,7 @@ class Extension implements Command } catch (Throwable $e) { $io->writeLine($e->getMessage()); + $io->setExitStatus(1); return; } @@ -136,6 +139,7 @@ class Extension implements Command if (!$name) { $io->writeLine("Can't install. Bad manifest.json file."); + $io->setExitStatus(1); return; } @@ -148,6 +152,7 @@ class Extension implements Command catch (Throwable $e) { $io->writeLine(""); $io->writeLine($e->getMessage()); + $io->setExitStatus(1); return; } @@ -173,6 +178,7 @@ class Extension implements Command if (!$record) { $io->writeLine("Extension with ID '{$id}' is not installed."); + $io->setExitStatus(1); return; } @@ -182,6 +188,7 @@ class Extension implements Command else { if (!$name) { $io->writeLine("Can't uninstall. No --name or --id specified."); + $io->setExitStatus(1); return; } @@ -196,6 +203,7 @@ class Extension implements Command if (!$record) { $io->writeLine("Extension '{$name}' is not installed."); + $io->setExitStatus(1); return; } @@ -213,6 +221,7 @@ class Extension implements Command catch (Throwable $e) { $io->writeLine(""); $io->writeLine($e->getMessage()); + $io->setExitStatus(1); return; } @@ -221,11 +230,11 @@ class Extension implements Command if ($toKeep) { $io->writeLine("Extension '{$name}' is uninstalled."); + $io->setExitStatus(1); return; } - try { $manager->delete(['id' => $id]); } diff --git a/application/Espo/Core/Console/Commands/RunJob.php b/application/Espo/Core/Console/Commands/RunJob.php index 091c6649de..71e322f097 100644 --- a/application/Espo/Core/Console/Commands/RunJob.php +++ b/application/Espo/Core/Console/Commands/RunJob.php @@ -110,6 +110,7 @@ class RunJob implements Command } $io->writeLine($message); + $io->setExitStatus(1); return; } diff --git a/application/Espo/Core/Console/Commands/SetPassword.php b/application/Espo/Core/Console/Commands/SetPassword.php index 9bdd0a4c9e..15afdedab2 100644 --- a/application/Espo/Core/Console/Commands/SetPassword.php +++ b/application/Espo/Core/Console/Commands/SetPassword.php @@ -55,6 +55,7 @@ class SetPassword implements Command if (!$userName) { $io->writeLine("User name must be specified."); + $io->setExitStatus(1); return; } @@ -67,6 +68,7 @@ class SetPassword implements Command if (!$user) { $io->writeLine("User '{$userName}' not found."); + $io->setExitStatus(1); return; } @@ -74,9 +76,8 @@ class SetPassword implements Command if (!in_array($user->get('type'), ['admin', 'super-admin', 'portal', 'regular'])) { $userType = $user->get('type'); - $io->writeLine( - "Can't set password for a user of the type '{$userType}'." - ); + $io->writeLine("Can't set password for a user of the type '{$userType}'."); + $io->setExitStatus(1); return; } @@ -87,13 +88,12 @@ class SetPassword implements Command if (!$password) { $io->writeLine("Password can not be empty."); + $io->setExitStatus(1); return; } - $hash = $this->passwordHash; - - $user->set('password', $hash->hash($password)); + $user->set('password', $this->passwordHash->hash($password)); $em->saveEntity($user);