Skip to content

Commit

Permalink
[Console] Fixed argument parsing when a single dash is passed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Sep 12, 2013
1 parent b591419 commit 42019f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -84,7 +84,7 @@ protected function parse()
$parseOptions = false;
} elseif ($parseOptions && 0 === strpos($token, '--')) {
$this->parseLongOption($token);
} elseif ($parseOptions && '-' === $token[0]) {
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
$this->parseShortOption($token);
} else {
$this->parseArgument($token);
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
Expand Up @@ -254,4 +254,11 @@ public function provideGetParameterOptionValues()
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'),
);
}

public function testParseSingleDashAsArgument()
{
$input = new ArgvInput(array('cli.php', '-'));
$input->bind(new InputDefinition(array(new InputArgument('file'))));
$this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument');
}
}

0 comments on commit 42019f6

Please sign in to comment.