Skip to content

Commit fc2e168

Browse files
committed
fixes
1 parent 8c21f3c commit fc2e168

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Illuminate/Console/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function parse($expression)
2020
throw new InvalidArgumentException('Console command definition is empty.');
2121
}
2222

23-
preg_match('/.*?\s/', $expression, $matches);
23+
preg_match('/[^\s]+/', $expression, $matches);
2424

2525
if (isset($matches[0])) {
2626
$name = trim($matches[0]);

tests/Console/ConsoleParserTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ class ConsoleParserTest extends PHPUnit_Framework_TestCase
66
{
77
public function testBasicParameterParsing()
88
{
9+
$results = Parser::parse('command:name');
10+
11+
$this->assertEquals('command:name', $results[0]);
12+
913
$results = Parser::parse('command:name {argument} {--option}');
1014

1115
$this->assertEquals('command:name', $results[0]);
@@ -32,6 +36,18 @@ public function testBasicParameterParsing()
3236
$this->assertTrue($results[2][0]->acceptValue());
3337
$this->assertTrue($results[2][0]->isArray());
3438

39+
$results = Parser::parse('command:name {argument?* : The argument description.} {--option=* : The option description.}');
40+
41+
$this->assertEquals('command:name', $results[0]);
42+
$this->assertEquals('argument', $results[1][0]->getName());
43+
$this->assertEquals('The argument description.', $results[1][0]->getDescription());
44+
$this->assertTrue($results[1][0]->isArray());
45+
$this->assertFalse($results[1][0]->isRequired());
46+
$this->assertEquals('option', $results[2][0]->getName());
47+
$this->assertEquals('The option description.', $results[2][0]->getDescription());
48+
$this->assertTrue($results[2][0]->acceptValue());
49+
$this->assertTrue($results[2][0]->isArray());
50+
3551
$results = Parser::parse('command:name
3652
{argument?* : The argument description.}
3753
{--option=* : The option description.}');

0 commit comments

Comments
 (0)