diff --git a/src/Commando/Command.php b/src/Commando/Command.php index c7fde92..2851175 100755 --- a/src/Commando/Command.php +++ b/src/Commando/Command.php @@ -671,9 +671,17 @@ public function getFlags() public function getArgumentValues() { $this->parseIfNotParsed(); + + $arguments = $this->arguments; + $arguments = array_filter($arguments, function(Option $argument){ + $argumentValue = $argument->getValue(); + return isset($argumentValue); + }); + + return array_map(function(Option $argument) { return $argument->getValue(); - }, $this->arguments); + }, $arguments); } /** diff --git a/tests/Commando/CommandTest.php b/tests/Commando/CommandTest.php index dbd6c1d..8d44bcf 100755 --- a/tests/Commando/CommandTest.php +++ b/tests/Commando/CommandTest.php @@ -200,6 +200,13 @@ public function testGetValues() $this->assertEquals(array('v3', 'v4', 'v5'), $cmd->getArgumentValues()); $this->assertEquals(array('a' => 'v1', 'b' => 'v2'), $cmd->getFlagValues()); + + $tokens = array('filename'); + $cmd = new Command($tokens); + $cmd + ->argument(); + + $this->assertEmpty($cmd->getArgumentValues()); } /** @@ -241,4 +248,4 @@ public function testDefineFromSubclass() $this->assertInstanceOf('Commando\Test\AnotherCommand', $cmd); } -} \ No newline at end of file +}