diff --git a/src/mako/reactor/CommandInterface.php b/src/mako/reactor/CommandInterface.php
index 7e2d837ab..e1061338d 100644
--- a/src/mako/reactor/CommandInterface.php
+++ b/src/mako/reactor/CommandInterface.php
@@ -22,6 +22,16 @@ interface CommandInterface
*/
public const int STATUS_ERROR = 1;
+ /**
+ * Incorrect usage status code.
+ */
+ public const int STATUS_INCORRECT_USAGE = 2;
+
+ /**
+ * Unknown command status code.
+ */
+ public const int STATUS_UNKNOWN_COMMAND = 127;
+
/**
* Returns the command.
*
diff --git a/src/mako/reactor/Reactor.php b/src/mako/reactor/Reactor.php
index 70fc50c0f..992c0c5b2 100644
--- a/src/mako/reactor/Reactor.php
+++ b/src/mako/reactor/Reactor.php
@@ -289,7 +289,7 @@ protected function unknownCommand(string $command): int
$this->listCommands();
- return CommandInterface::STATUS_ERROR;
+ return CommandInterface::STATUS_UNKNOWN_COMMAND;
}
/**
@@ -375,7 +375,7 @@ public function run(): int
catch (ArgumentException|UnexpectedValueException $e) {
$this->output->errorLn("{$e->getMessage()}");
- return CommandInterface::STATUS_ERROR;
+ return CommandInterface::STATUS_INCORRECT_USAGE;
}
}
}
diff --git a/tests/unit/reactor/ReactorTest.php b/tests/unit/reactor/ReactorTest.php
index 16425f751..c1c5559d1 100644
--- a/tests/unit/reactor/ReactorTest.php
+++ b/tests/unit/reactor/ReactorTest.php
@@ -77,7 +77,7 @@ public function testNoInput(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -88,7 +88,7 @@ public function testNoInput(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('getFormatter')->andReturn(null);
@@ -131,17 +131,17 @@ public function testNoInput(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -166,7 +166,7 @@ public function testNoInputWithMute(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -177,7 +177,7 @@ public function testNoInputWithMute(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('mute')->once();
@@ -222,17 +222,17 @@ public function testNoInputWithMute(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -255,7 +255,7 @@ public function testUknownCommand(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -266,7 +266,7 @@ public function testUknownCommand(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('getFormatter')->andReturn(null);
@@ -275,12 +275,12 @@ public function testUknownCommand(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
@@ -289,7 +289,7 @@ public function testUknownCommand(): void
$exitCode = $reactor->run();
- $this->assertSame(1, $exitCode);
+ $this->assertSame(127, $exitCode);
}
/**
@@ -301,7 +301,7 @@ public function testUknownCommandWithSuggestion(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -312,7 +312,7 @@ public function testUknownCommandWithSuggestion(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('write')->times(3);
@@ -325,17 +325,17 @@ public function testUknownCommandWithSuggestion(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -344,7 +344,7 @@ public function testUknownCommandWithSuggestion(): void
$exitCode = $reactor->run();
- $this->assertSame(1, $exitCode);
+ $this->assertSame(127, $exitCode);
}
/**
@@ -356,7 +356,7 @@ public function testUknownCommandWithNoSuggestion(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -367,7 +367,7 @@ public function testUknownCommandWithNoSuggestion(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('write')->times(3);
@@ -380,17 +380,17 @@ public function testUknownCommandWithNoSuggestion(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -399,7 +399,7 @@ public function testUknownCommandWithNoSuggestion(): void
$exitCode = $reactor->run();
- $this->assertSame(1, $exitCode);
+ $this->assertSame(127, $exitCode);
}
/**
@@ -411,7 +411,7 @@ public function testCommandWithInvalidArguments(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -426,19 +426,19 @@ public function testCommandWithInvalidArguments(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('errorLn')->once()->with('Invalid argument [ bar ].');
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
$dispatcher->shouldReceive('dispatch')->once()->with('mako\tests\unit\reactor\Foo', [])->andThrow(new InvalidArgumentException('Invalid argument [ bar ].'));
@@ -451,7 +451,7 @@ public function testCommandWithInvalidArguments(): void
$exitCode = $reactor->run();
- $this->assertSame(1, $exitCode);
+ $this->assertSame(2, $exitCode);
}
/**
@@ -463,7 +463,7 @@ public function testCommandWithInvalidInput(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -478,19 +478,19 @@ public function testCommandWithInvalidInput(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('errorLn')->once()->with('Unexpected value.');
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
$dispatcher->shouldReceive('dispatch')->once()->with('mako\tests\unit\reactor\Foo', [])->andThrow(new UnexpectedValueException('Unexpected value.'));
@@ -503,7 +503,7 @@ public function testCommandWithInvalidInput(): void
$exitCode = $reactor->run();
- $this->assertSame(1, $exitCode);
+ $this->assertSame(2, $exitCode);
}
/**
@@ -515,7 +515,7 @@ public function testCommand(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -530,17 +530,17 @@ public function testCommand(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
$dispatcher->shouldReceive('dispatch')->once()->with('mako\tests\unit\reactor\Foo', ['test' => 'bar']);
@@ -565,7 +565,7 @@ public function testDisplayCommandHelp(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -578,7 +578,7 @@ public function testDisplayCommandHelp(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('getFormatter')->andReturn(null);
@@ -609,17 +609,17 @@ public function testDisplayCommandHelp(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();
@@ -640,7 +640,7 @@ public function testDisplayCommandHelpWithoutAttributes(): void
//
- /** @var \mako\cli\input\Input|\Mockery\MockInterface $input */
+ /** @var Input|Mockery\MockInterface $input */
$input = Mockery::mock(Input::class);
$input->shouldReceive('getArgumentParser')->andReturn($argvParser);
@@ -653,7 +653,7 @@ public function testDisplayCommandHelpWithoutAttributes(): void
//
- /** @var \mako\cli\output\Output|\Mockery\MockInterface $output */
+ /** @var Mockery\MockInterface|Output $output */
$output = Mockery::mock(Output::class);
$output->shouldReceive('getFormatter')->andReturn(null);
@@ -684,17 +684,17 @@ public function testDisplayCommandHelpWithoutAttributes(): void
//
- /** @var \mako\syringe\Container|\Mockery\MockInterface $container */
+ /** @var Container|Mockery\MockInterface $container */
$container = Mockery::mock(Container::class);
//
- /** @var \mako\reactor\Dispatcher|\Mockery\MockInterface $dispatcher */
+ /** @var Dispatcher|Mockery\MockInterface $dispatcher */
$dispatcher = Mockery::mock(Dispatcher::class);
//
- /** @var \mako\reactor\Reactor|\Mockery\MockInterface $reactor */
+ /** @var Mockery\MockInterface|Reactor $reactor */
$reactor = Mockery::mock(Reactor::class, [$input, $output, $container, $dispatcher])
->makePartial()
->shouldAllowMockingProtectedMethods();