-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Too many arguments message contains an incorrect number of missing arguments #38904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hm.. I think there is a terminology confusion here. The actual command/program/binary you are running is When you are running:
It is the Does it make more sense? |
Well, I think the problem is that the contents of the error message depend on the command that is used. More precisely, the names of the actual expected arguments (except from So I think it is better to formulate the exception in the context of the command that is used, i.e. use something like
instead of
|
Yeah. I can agree with that. Or even better:
|
Yes that's even better. Thanks for the PR, @Nyholm! |
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Console] Make error message more verbose | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #38904 | License | MIT | Doc PR | no This will make the error message a bit more verbose when you are using too many or too few arguments. Commits ------- ef221e8 [Console] Make error message more verbose
Symfony version(s) affected: 5.1.8 (and earlier)
Description
Whenever a Symfony Console command is called with too many arguments, a "Too many arguments" error is shown on the CLI. This message also states which arguments are expected. But this message always contains
"command"
as an extra argument. This can be confusing for the user, as the reported number of arguments is one off with what it should be.How to reproduce
Install the Symfony skeleton and run the following command:
It shows the following message:
This is incorrect, as the command itself expects no arguments at all.
Similarly, the command
shows the message:
Here I would have expected a message stating that that
"name"
and"file"
are the expected arguments, but not"command"
.Possible Solution
The message is thrown on line 139 of src/Symfony/Component/Console/Input/ArgvInput.php.
Here it can be seen that keys of the
$this->definition->getArguments()
array are printed.The simplest solution to fix this seems to remove the first key of the array when creating the exception message.
The text was updated successfully, but these errors were encountered: