1
0
Fork 0

refactored alignment of text output

pull/2075/head
Benoît Merlet 2013-07-12 15:40:09 +02:00
parent bf0b42efaa
commit fbbd6f8999
1 changed files with 8 additions and 6 deletions

View File

@ -48,20 +48,22 @@ EOT
$versionParser = new VersionParser;
$nameLength = strlen($root->getPrettyName());
$versionLength = strlen($versionParser->formatVersion($root));
foreach ($repo->getPackages() as $package) {
$packages[$package->getName()] = $package;
$nameLength = max($nameLength, strlen($package->getPrettyName()));
$versionLength = max($versionLength, strlen($versionParser->formatVersion($package)));
}
ksort($packages);
switch ($format = $input->getOption('format')) {
case 'text':
$nameLength = strlen($root->getPrettyName());
$versionLength = strlen($versionParser->formatVersion($root));
foreach ($packages as $package) {
$nameLength = max($nameLength, strlen($package->getPrettyName()));
$versionLength = max($versionLength, strlen($versionParser->formatVersion($package)));
}
$formatRowCallback = function (PackageInterface $package) use ($versionParser, $nameLength, $versionLength) {
return sprintf(
' %s %s %s',