-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] HelpCommand strips arguments with same names as output styles #24225
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
While a simple fix is to prepend the first
|
using edit: nice catch btw 👍 |
Yes, looks like this could be handled more gracefully in the |
PRed a fix in #24455 |
This PR was merged into the 2.7 branch. Discussion ---------- [Console] Escape command usage | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24225 | License | MIT | Doc PR | ø Escape the console usage to prevent arguments named `info` or similar to be formatted. Commits ------- 2141056 Escape command usage when displaying it in the text descriptor
When a console command defines one or more input arguments that have the same name(s) as defined OutputFormatterStyles, the HelpCommand output strips those arguments from the Usage section of the output and applies that style to the content that follows.
This is occurring because in
Symfony\Component\Console\Input\InputDefinition::getSynopsis()
(https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Input/InputDefinition.php#L398) those argument names are wrapped in<
and>
and so the argument is treated as the opening tag of a style wrapper:An example command that defines the argument names "info", "comment", and "foo" as follows:
... would appear as follows when running
help
for that command. Note that the yellow foreground color of the defaultcomment
style is being applied to the following text in the output:... when the expected output would be more like:
The text was updated successfully, but these errors were encountered: