Skip to content

Commit

Permalink
merged branch jakzal/console-single-dash-argument (PR #9014)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.2 branch.

Discussion
----------

[Console] Fixed argument parsing when a single dash is passed.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8986
| License       | MIT
| Doc PR        |

Commits
-------

42019f6 [Console] Fixed argument parsing when a single dash is passed.
  • Loading branch information
fabpot committed Sep 13, 2013
2 parents 2742310 + 42019f6 commit 7d7b583
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 7d7b583

Please sign in to comment.