Skip to content

Commit 6ca33ab

Browse files
committed
reset commands when parsing new arguments
1 parent be4761b commit 6ca33ab

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Commands.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function addCommand(Command $command)
2828

2929
public function parse($arguments = null)
3030
{
31+
$this->command = null;
3132
parent::parse($arguments);
3233

3334
if (count($this->getOperands()) > 0) {

tests/Commands/ParseTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,15 @@ public function testStoresTheCalledCommand()
7676

7777
self::assertSame($command, $commands->getCommand());
7878
}
79+
80+
public function testResetsTheCommand()
81+
{
82+
$commands = new Commands();
83+
$commands->addCommand(new Command('help', 'Show the help for command', 'var_dump'));
84+
$commands->parse('help');
85+
86+
$commands->parse('');
87+
88+
self::assertNull($commands->getCommand());
89+
}
7990
}

0 commit comments

Comments
 (0)