This commit is contained in:
Niklas Keller
2018-01-11 10:36:45 +01:00
parent e3d7723da3
commit 56955155fe

View File

@@ -144,8 +144,9 @@ $injector->share(new AcmeFactory);
$injector->share(new Amp\Artax\DefaultClient); $injector->share(new Amp\Artax\DefaultClient);
$command = $injector->make($class); $command = $injector->make($class);
$exitCode = 1;
Loop::run(function () use ($command, $climate) { Loop::run(function () use ($command, $climate, &$exitCode) {
$handler = function ($e) use ($climate) { $handler = function ($e) use ($climate) {
$error = (string) $e; $error = (string) $e;
$lines = explode("\n", $error); $lines = explode("\n", $error);
@@ -164,13 +165,13 @@ Loop::run(function () use ($command, $climate) {
$exitCode = yield $command->execute($climate->arguments); $exitCode = yield $command->execute($climate->arguments);
if ($exitCode === null) { if ($exitCode === null) {
exit(0); $exitCode = 0;
} }
exit($exitCode);
} catch (Throwable $e) { } catch (Throwable $e) {
$handler($e); $handler($e);
} }
Loop::stop(); Loop::stop();
}); });
exit($exitCode);