Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private function dispatch(Output $output, array $arguments): int
if ($arguments === []) {
$arguments = ['help', self::DEFAULT_COMMAND];
} elseif ($arguments[0] !== 'help') {
array_unshift($arguments, 'help');
$arguments = ['help', $arguments[0]];
}

// Options supplied alongside --help were meant for the target command,
Expand Down
9 changes: 9 additions & 0 deletions tests/system/CLI/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ public function testHelpShortcutStripsOptionsMeantForTargetCommand(): void
$this->assertStringContainsString('serve [options]', $this->getStreamFilterBuffer());
}

public function testHelpOptionStripsArgumentsMeantForTargetCommand(): void
{
$this->initializeConsole('env', 'production', '--help');
$exitCode = (new Console())->run();

$this->assertSame(EXIT_SUCCESS, $exitCode);
$this->assertStringContainsString('env [options] [--] [<environment>]', $this->getStreamFilterBuffer());
}

public function testHelpArgumentAndHelpOptionCombined(): void
{
$this->initializeConsole('help', '--help');
Expand Down
Loading