PHP: Add lexit function for easy exiting with text

This commit is contained in:
Tim
2025-05-19 18:41:49 +02:00
parent ea00b5c47e
commit 7f610dc31a
3 changed files with 19 additions and 17 deletions

View File

@ -12,8 +12,7 @@ $argvParser = new ArgvParser(
);
$parsed = $argvParser->parseArgv($argv);
if ($parsed === false) {
line('Usage: ' . __FILE__ . ' ' . $argvParser->getOptionsHelp());
exit(1);
lexit('Usage: ' . __FILE__ . ' ' . $argvParser->getOptionsHelp(), 1);
}
$cwd = getcwd();
@ -29,11 +28,10 @@ $config = new config($stowPath);
$targetPath = $config->get('targetPath', dirname($stowPath, 2));
if (!is_dir($stowPath)) {
line("Directory '$stowName' does not exist");
exit(1);
lexit("Directory '$stowName' does not exist", 1);
}
$stow = new stow($action, $backup, $force, $unwrap);
$stow->run($stowPath, $targetPath);
exit(0);
lexit('Done successfully');