Skip to content

Commit 8336083

Browse files
authored
fix: drop extra arguments when --help is passed (#10728)
1 parent 7fd9386 commit 8336083

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎system/CLI/Console.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function dispatch(Output $output, array $arguments): int
128128
if ($arguments === []) {
129129
$arguments = ['help', self::DEFAULT_COMMAND];
130130
} elseif ($arguments[0] !== 'help') {
131-
array_unshift($arguments, 'help');
131+
$arguments = ['help', $arguments[0]];
132132
}
133133

134134
// Options supplied alongside --help were meant for the target command,

‎tests/system/CLI/ConsoleTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ public function testHelpShortcutStripsOptionsMeantForTargetCommand(): void
411411
$this->assertStringContainsString('serve [options]', $this->getStreamFilterBuffer());
412412
}
413413

414+
public function testHelpOptionStripsArgumentsMeantForTargetCommand(): void
415+
{
416+
$this->initializeConsole('env', 'production', '--help');
417+
$exitCode = (new Console())->run();
418+
419+
$this->assertSame(EXIT_SUCCESS, $exitCode);
420+
$this->assertStringContainsString('env [options] [--] [<environment>]', $this->getStreamFilterBuffer());
421+
}
422+
414423
public function testHelpArgumentAndHelpOptionCombined(): void
415424
{
416425
$this->initializeConsole('help', '--help');

0 commit comments

Comments
 (0)