Skip to content
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

[Console] Help command reports wrong usage in a single command application #27953

Closed
Chi-teck opened this issue Jul 14, 2018 · 5 comments
Closed

Comments

@Chi-teck
Copy link
Contributor

Chi-teck commented Jul 14, 2018

Symfony version(s) affected: 4.1.1

Description
The usage section of help command output should not print command name as it is not supported.

How to reproduce

  • Create a simple single command application using this example from documentation.
  • Save it to ./bin/test.php file.
  • Run the script with some argument (./bin/test.php foo) and make sure it works as expected.
  • Run the script as it suggested by help command (./bin/test.php echo foo).
  • The following error should appear: Too many arguments, expected arguments "foo".
@blixit
Copy link

blixit commented Jul 17, 2018

@Chi-teck I don't understand your issue. What behavior are you expecting ?

@Chi-teck
Copy link
Contributor Author

@blixit I expect that help command prints correct command usage. Currently of you copy/paste usage from help output you will get the error mentioned above.

@Chi-teck Chi-teck changed the title [Console] Help command reports wrong usage when implemented as a single command application [Console] Help command reports wrong usage in a a single command application Jul 17, 2018
@Chi-teck Chi-teck changed the title [Console] Help command reports wrong usage in a a single command application [Console] Help command reports wrong usage in a single command application Jul 17, 2018
@xabbuh
Copy link
Member

xabbuh commented Aug 6, 2018

Status: Reviewed

@dmanners
Copy link

As far as I can see the issue happens because of the resetting of the arguments to empty in the getDefinition method: https://github.com/symfony/console/blame/master/Application.php#L305

After playing around with the example and removing this line the expected results happen.

That being said I am not sure really sure why this resetting of arguments was done in the first place. I would be happy to make a PR for this change if people think it is the right approach.

@chalasr
Copy link
Member

chalasr commented Jan 10, 2019

Fixed in #29617.

@chalasr chalasr closed this as completed Jan 10, 2019
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

6 participants