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

[FrameworkBundle] Remove env var table from AboutCommand #34768

Merged
merged 1 commit into from Dec 26, 2019
Merged

[FrameworkBundle] Remove env var table from AboutCommand #34768

merged 1 commit into from Dec 26, 2019

Conversation

tuqqu
Copy link
Contributor

@tuqqu tuqqu commented Dec 2, 2019

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

Fixed AboutCommand output by shortening environment variable value (replacing with ...) to fit the screen width if the value is too long.

Right now all output is a mess if it does not fit in the terminal window.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 3, 2019

it's considerable to use the new Console dumper (#28898) for env var values, that would improve display as well.

The CliDumper has setMaxStringWidth, so if we can pass such a value (as calculated here) we can depend on existing building blocks :)

something like

diff --git a/Command/AboutCommand.php b/Command/AboutCommand.php
index b9fbe67..feee4e6 100644
--- a/Command/AboutCommand.php
+++ b/Command/AboutCommand.php
@@ -12,6 +12,7 @@
 namespace Symfony\Bundle\FrameworkBundle\Command;
 
 use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Helper\Dumper;
 use Symfony\Component\Console\Helper\Helper;
 use Symfony\Component\Console\Helper\TableSeparator;
 use Symfony\Component\Console\Input\InputInterface;
@@ -90,12 +91,13 @@ EOT
         ];
 
         if ($dotenv = self::getDotenvVars()) {
+            $dumper = new Dumper($io);
             $rows = array_merge($rows, [
                 new TableSeparator(),
                 ['<info>Environment (.env)</>'],
                 new TableSeparator(),
-            ], array_map(function ($value, $name) {
-                return [$name, $value];
+            ], array_map(function ($value, $name) use ($dumper) {
+                return [$name, $dumper($value, $maxLength)];
             }, $dotenv, array_keys($dotenv)));
         }

@nicolas-grekas nicolas-grekas changed the title [FrameworkBundle] Long envvar value shortened to fit screen in AboutC… [FrameworkBundle] Long envvar value shortened to fit screen in AboutCommand Dec 3, 2019
@tuqqu
Copy link
Contributor Author

tuqqu commented Dec 3, 2019

@ro0NL I'm not sure. Dumper::__invoke() does not allow to pass string's max length as the second parameter. Or are you suggesting to tweak its behaviour in this pr?

If so, dump's output is standing out with it's bright colours and double quotes from all the rest. Do we really want this?

If so, I could take a look into this.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 3, 2019

Or are you suggesting to tweak its behaviour in this pr?

yep :)

If so, dump's output is standing out with it's bright colours and double quotes from all the rest. Do we really want this?

IMHO yes, but perhaps post a screenshot to see what others think. Maybe it's too much indeed ... i was mostly triggered for being able to reuse CliDumper::setMaxStringWidth :)

@nicolas-grekas nicolas-grekas added this to the next milestone Dec 3, 2019
@tuqqu
Copy link
Contributor Author

tuqqu commented Dec 3, 2019

@ro0NL I decided against using Dumper since we would rely on CliDumper::setMaxStringWidth() and it is part of VarDumper which is mostly a require-dev package, plus it adds a new dependency (on symfony/console).

So I rewrote it a bit and it looks quite nice. I added a pic
Screenshot 2019-12-03 at 23 33 12

Could you please review my code?

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

decided against using Dumper since we would rely on CliDumper::setMaxStringWidth() and it is part of VarDumper which is mostly a require-dev package

good point, i forgot we need to account for the fallback implementation as well.

LGTM in general 👍

@tuqqu
Copy link
Contributor Author

tuqqu commented Dec 4, 2019

@ro0NL fixed all

@nicolas-grekas
Copy link
Member

Not sure about this: while it improves the display, what if I do want to get the full value, eg to copy/paste it somewhere else?

@ro0NL
Copy link
Contributor

ro0NL commented Dec 15, 2019

from experience, i agree about can be over-cluttered with output. Typically access tokens & co completely break the table

image

the original intend was always "debugging"; give a hint about the actual values being used. Truncating does not defeat this purpose IMHO.

what if I do want to get the full value

bin/console debug:container --env-var APP_SECRET :)

@nicolas-grekas
Copy link
Member

Wouldn't it make more sense to just remove this table with env vars?
There is already bin/console debug:container --env-vars if one wants to display them.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 15, 2019

hmpf... yes. There's a subtle difference.. (envs managed by .env vs envs used in DI), but i agree it's not really significant.

Alternatively, what about displaying SYMFONY_DOTENV_VARS comma separated in about, to not loose this feature (it's also shown in the webprofiler e.g.)

@ro0NL
Copy link
Contributor

ro0NL commented Dec 16, 2019

i tend to agree we should remove the Environment table in about. Actually the web profiler shows the server parameters used for that request (and highlights which are from .env)... this concept doesnt exists for the console.

The current table was a solution, prior to the later added debug:container --env-vars.

Also we imply this are the actual values in .env, which is false :) the feature replacement is looking at .env really 😅

@tuqqu
Copy link
Contributor Author

tuqqu commented Dec 18, 2019

@ro0NL @nicolas-grekas ok, I see. I pushed a new commit which removes env var table completely.

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

probably best to update the PR title

@tuqqu tuqqu changed the title [FrameworkBundle] Long envvar value shortened to fit screen in AboutCommand [FrameworkBundle] Remove env var table from AboutCommand Dec 18, 2019
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.

Arthur thanks for this contribution (and congrats for being your first Symfony contribution!). And thanks for your patience during the review process.

@nicolas-grekas
Copy link
Member

Thank you @tuqqu.

nicolas-grekas added a commit that referenced this pull request Dec 26, 2019
… (tuqqu)

This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

[FrameworkBundle] Remove env var table from AboutCommand

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

Fixed AboutCommand output by shortening environment variable value (replacing with `...`) to fit the screen width if the value is too long.

Right now all output is a mess if it does not fit in the terminal window.

Commits
-------

6962da9 [FrameworkBundle] Remove env var table from AboutCommand
@nicolas-grekas nicolas-grekas merged commit 6962da9 into symfony:master Dec 26, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
GromNaN added a commit to GromNaN/symfony that referenced this pull request Sep 2, 2021
GromNaN added a commit to GromNaN/symfony that referenced this pull request Sep 2, 2021
fabpot added a commit that referenced this pull request Sep 3, 2021
…ection was removed (GromNaN)

This PR was merged into the 5.3 branch.

Discussion
----------

[Framework] Clean "about" command help after Environment section was removed

In Symfony 5.1 the "Environment" section of "about" command was removed (see #34768). The help text needs to be updated as a consequence.

The sentence "It will not be shown if no variables were found." is particularly puzzling since the section is never shown.

| Q             | A
| ------------- | ---
| Branch?       | 5.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34768
| License       | MIT

Commits
-------

a4306d2 Clean about command description after Environment section was removed
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.

None yet

5 participants