Skip to content

Commit 8bca576

Browse files
committed
[TASK] Add exit code to cli commands
All cli commands will now return an exit code depending on whether they found any problems: - 0 : everything ok, nothing found - 1 : found problems Resolves: #619
1 parent 11b9024 commit 8bca576

8 files changed

+17
-8
lines changed

Classes/Command/DeleteChildrenWithNonExistingParentCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
5151
$this->integrityFix->deleteChildrenWithNonExistingParent($warning);
5252
}
5353
}
54-
return 0;
54+
// return with exit code !0 if errors found
55+
return count($res['warnings']) > 0 ? 1 : 0;
5556
}
5657
}

Classes/Command/DeleteChildrenWithWrongPidCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
5151
$this->integrityFix->deleteChildrenWithWrongPid($error);
5252
}
5353
}
54-
return 0;
54+
// return with exit code !0 if errors found
55+
return count($res['errors']) > 0 ? 1 : 0;
5556
}
5657
}

Classes/Command/FixContainerParentForConnectedModeCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
4646
$this->integrityFix->changeContainerParentToDefaultLanguageContainer($error);
4747
}
4848
}
49-
return 0;
49+
// return with exit code !0 if errors found
50+
return count($res['errors']) > 0 ? 1 : 0;
5051
}
5152
}

Classes/Command/FixLanguageModeCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
4848
}
4949
}
5050
$this->integrityFix->languageMode($errors);
51-
return 0;
51+
// return with exit code !0 if errors found
52+
return count($res['errors']) > 0 ? 1 : 0;
5253
}
5354
}

Classes/Command/IntegrityCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function execute(InputInterface $input, OutputInterface $output): int
5151
}
5252
if (count($res['warnings']) === 0 && count($res['errors']) === 0) {
5353
$io->success('Good Job, no errors/warnings!');
54+
return 0;
5455
}
55-
return 0;
56+
// return with exit code !0 if errors found
57+
return 1;
5658
}
5759
}

Classes/Command/SortingCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
6969
$output->writeln('- all good, nothing to do here');
7070
}
7171
}
72-
73-
return self::SUCCESS;
72+
// return with exit code !0 if errors found
73+
return count($errors) > 0 ? 1 : 0;
7474
}
7575
}

Classes/Command/SortingInPageCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
6565
if (empty($errors)) {
6666
$output->writeln('migration finished');
6767
}
68-
return 0;
68+
// return with exit code !0 if errors found
69+
return count($errors) > 0 ? 1 : 0;
6970
}
7071
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ bin/typo3 container:deleteChildrenWithWrongPid
208208
bin/typo3 container:deleteChildrenWithNonExistingParent
209209
```
210210

211+
Commands will generally exit with 0 on non-error and exit with !0 if an error was found.
212+
211213
## TODOs
212214
- Integrity proofs
213215
- List module actions

0 commit comments

Comments
 (0)