Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[FrameworkBundle] Long envvar value shortened to fit screen in AboutCommand #34768
Conversation
…ommand
This comment has been minimized.
This comment has been minimized.
it's considerable to use the new Console dumper (#28898) for env var values, that would improve display as well. The CliDumper has 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)));
} |
This comment has been minimized.
This comment has been minimized.
@ro0NL I'm not sure. If so, If so, I could take a look into this. |
This comment has been minimized.
This comment has been minimized.
yep :)
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 |
This comment has been minimized.
This comment has been minimized.
@ro0NL I decided against using So I rewrote it a bit and it looks quite nice. I added a pic Could you please review my code? |
good point, i forgot we need to account for the fallback implementation as well. LGTM in general |
return max(18/* longest column text */, ...array_map('strlen', array_keys($dotenvVars))); | ||
} | ||
private static function adjustLength(string $value, int $maxLength): string |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -141,4 +144,28 @@ private static function getDotenvVars(): array | |||
return $vars; | |||
} | |||
private static function getLongestColumnLength(array $dotenvVars): int |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@ro0NL fixed all |
tuqqu commentedDec 2, 2019
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.