Skip to content

Commit 7af59cd

Browse files
SpacePossumfabpot
authored andcommitted
[Console] Overcomplete argument exception message tweak.
1 parent 35c70be commit 7af59cd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ private function parseArgument($token)
174174

175175
// unexpected argument
176176
} else {
177-
throw new \RuntimeException('Too many arguments.');
177+
$all = $this->definition->getArguments();
178+
if (count($all)) {
179+
throw new \RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
180+
}
181+
182+
throw new \RuntimeException(sprintf('No arguments expected, got "%s".', $token));
178183
}
179184
}
180185

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ public function provideInvalidInput()
183183
array(
184184
array('cli.php', 'foo', 'bar'),
185185
new InputDefinition(),
186-
'Too many arguments.',
186+
'No arguments expected, got "foo".',
187+
),
188+
array(
189+
array('cli.php', 'foo', 'bar'),
190+
new InputDefinition(array(new InputArgument('number'))),
191+
'Too many arguments, expected arguments "number".',
192+
),
193+
array(
194+
array('cli.php', 'foo', 'bar', 'zzz'),
195+
new InputDefinition(array(new InputArgument('number'), new InputArgument('county'))),
196+
'Too many arguments, expected arguments "number" "county".',
187197
),
188198
array(
189199
array('cli.php', '--foo'),

0 commit comments

Comments
 (0)