exit status usage

This commit is contained in:
Yuri Kuznetsov
2022-05-17 16:51:34 +03:00
parent 502b6586f1
commit 4ccbf86589
3 changed files with 17 additions and 7 deletions
@@ -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]);
}
@@ -110,6 +110,7 @@ class RunJob implements Command
}
$io->writeLine($message);
$io->setExitStatus(1);
return;
}
@@ -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);