Skip to content

[Console] Table vertical rendering #41676

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

Merged
merged 1 commit into from
May 9, 2022

Conversation

yoannrenard
Copy link
Contributor

@yoannrenard yoannrenard commented Jun 11, 2021

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #41595
License MIT
Doc PR

This PR adds a way to render Console Tables vertically. This is inspired by the way MySQL and PostgreSQL do with the '\G' command terminator.
For example, if we use this vertical rendering for the command debug:validator, the command would show something like:

App\Entity\Foo
-------------------

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property: bar                                                                                                                                                       |
|     Name: Symfony\Component\Validator\Constraints\Length                                                                                                            |
|   Groups: Default, Foo                                                                                                                                              |
|  Options: [                                                                                                                                                         |
|   "maxMessage" => "This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.",   |
|   "minMessage" => "This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.", |
|   "exactMessage" => "This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.",                                 |
|   "charsetMessage" => "This value does not match the expected {{ charset }} charset.",                                                                              |
|   "max" => 75,                                                                                                                                                      |
|   "min" => 2,                                                                                                                                                       |
|   "charset" => "UTF-8",                                                                                                                                             |
|   "normalizer" => null,                                                                                                                                             |
|   "allowEmptyString" => false,                                                                                                                                      |
|   "payload" => null                                                                                                                                                 |
| ]                                                                                                                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ...                                                                                                                                                                 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Instead of :

App\Entity\Foo
-------------------

+----------+------------------------------------------------+------------------------------------------------+----------------------------------------------------------------------------------+
| Property | Name                                           | Groups                                         | Options                                                                          |
+----------+------------------------------------------------+------------------------------------------------+----------------------------------------------------------------------------------+
| bar      | Symfony\Component\Validator\Constraints\Length | Default, Foo                                   | [                                                                                |
|          |                                                |                                                |   "maxMessage" => "This value                                                    |
|          |                                                |                                                | is too long. It should have {{ limit }} character or less.|This value is too lon |
|          |                                                |                                                | g. It should have {{ limit }} characters or less.",                              |
|          |                                                |                                                |   "minMessage" => "This value                                                    |
|          |                                                |                                                | is too short. It should have {{ limit }} character or more.|This value is too sh |
|          |                                                |                                                | ort. It should have {{ limit }} characters or more.",                            |
|          |                                                |                                                |   "exactMessage" => "This valu                                                   |
|          |                                                |                                                | e should have exactly {{ limit }} character.|This value should have exactly {{ l |
|          |                                                |                                                | imit }} characters.",                                                            |
|          |                                                |                                                |   "charsetMessage" => "This va                                                   |
|          |                                                |                                                | lue does not match the expected {{ charset }} charset.",                         |
|          |                                                |                                                |   "max" => 75,                                                                   |
|          |                                                |                                                |   "min" => 2,                                                                    |
|          |                                                |                                                |   "charset" => "UTF-8                                                   |
|          |                                                |                                                | 208m",                                                                           |
|          |                                                |                                                |   "normalizer" => null                                                   |
|          |                                                |                                                | ;208m,                                                                           |
|          |                                                |                                                |   "allowEmptyString" => false                                                   |
|          |                                                |                                                | [0;38;5;208m,                                                                    |
|          |                                                |                                                |   "payload" => null                                                   |
|          |                                                |                                                | 8m                                                                               |
|          |                                                |                                                | ]                                                                                |
...
+----------+------------------------------------------------+------------------------------------------------+----------------------------------------------------------------------------------+

Which is hard to read.

@stof
Copy link
Member

stof commented Jun 11, 2021

Having 2 booleans named horizontal and vertical looks confusing to me.

@yoannrenard
Copy link
Contributor Author

I agree with you @stof
I was thinking of a parameter like $orientation, or $direction maybe, that could be neutral, horizontal or vertical. But I didn't like it either

@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Jun 12, 2021
@yoannrenard yoannrenard force-pushed the console_table_inline_render branch from 15e9ab8 to a37528e Compare June 12, 2021 10:12
@yoannrenard yoannrenard force-pushed the console_table_inline_render branch from d4a17b9 to 69b28e8 Compare July 20, 2021 17:06
Copy link
Contributor

@94noni 94noni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to have it in v5.4 :)

@yoannrenard yoannrenard force-pushed the console_table_inline_render branch from 69b28e8 to 1221afe Compare August 26, 2021 18:32
@fabpot fabpot modified the milestones: 5.4, 6.1 Nov 16, 2021
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a cool feature. Can you rebase it on 6.1 and adapt the syntax with PHP 8.1 capabilities?

@yoannrenard
Copy link
Contributor Author

Thanks for your review @GromNaN

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature! Thanks Yoann.

@chalasr
Copy link
Member

chalasr commented Apr 26, 2022

@yoannrenard Can you please rebase again on 6.1?

@yoannrenard yoannrenard force-pushed the console_table_inline_render branch from 1ed9549 to defd326 Compare May 2, 2022 08:58
Using an enum instead of 2 separated booleans

Rephrase changelog for better consistency
@GromNaN
Copy link
Member

GromNaN commented May 9, 2022

Thank you @yoannrenard.

@GromNaN GromNaN merged commit 8d5dd1b into symfony:6.1 May 9, 2022
@yoannrenard yoannrenard deleted the console_table_inline_render branch May 10, 2022 08:09
@yoannrenard
Copy link
Contributor Author

You are welcome @GromNaN

nicolas-grekas added a commit that referenced this pull request May 14, 2022
…ering (nicolas-grekas)

This PR was merged into the 6.1 branch.

Discussion
----------

[Console] fix CS for code related to Table vertical rendering

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

A quick review of #41676 made me submit this.

Commits
-------

41ff71e [Console] fix CS for code related to Table vertical rendering
@fabpot fabpot mentioned this pull request May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Table helper vertical rendering
9 participants