Skip to content

[Console] Synopsis in error message contains <command> as non-option argument #38906

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

Closed
aadmathijssen opened this issue Oct 30, 2020 · 3 comments

Comments

@aadmathijssen
Copy link

Symfony version(s) affected: 5.1.8

Description

When an exception occurs while validating or running a Symfony Console command, an error message is shown to the user.
The last line of the error message is a synopsis of how the command should be called. This synopsis is incorrect: it states that the first non-option argument should be <command>. But the command itself is already shown at the start of the synopsis.

How to reproduce

Install the Symfony skeleton and run the following command:

bin/console secrets:list --foo

An error is shown of which the last line is the following:

secrets:list [-r|--reveal] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

In this synopsis, <command> at the end of the line should not be there.

Similarly, the command

bin/console secrets:set --foo

also shows an error with the following last line:

secrets:set [-l|--local] [-r|--random [RANDOM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <name> [<file>]

Also in this synopsis, <command> should not be there.

Possible Solution

Unknown.

Additional context

The synopsis is printed on line 774 of src/Symfony/Component/Console/Application.php. On this line the method \Symfony\Component\Console\Command\Command::getSynopsis is called, which in turn calls \Symfony\Component\Console\Input\InputDefinition::getSynopsis. In this method, all non-option arguments are enclosed in < and > and are added to the synopsis; this happens on line 375 of src/Symfony/Component/Console/Input/InputDefinition.php. So the first element of $this->getArguments() is an argument with name command.

This issue is possibly related to #38904.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Could I get a reply or should I close this?

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants