1
0
Fork 0

[Command] Modifying the output of SearchCommand to make evenly-spaced package names for readability of results

pull/679/head
Ryan Weaver 2012-05-11 20:42:35 -05:00
parent 655588a5e0
commit 9e1ed5a52f
1 changed files with 8 additions and 2 deletions

View File

@ -62,6 +62,7 @@ EOT
$tokens = $input->getArgument('tokens');
$packages = array();
$maxPackageLength = 0;
foreach ($repos->getPackages() as $package) {
if ($package instanceof AliasPackage || isset($packages[$package->getName()])) {
continue;
@ -82,14 +83,19 @@ EOT
$packages[$package->getName()] = array(
'name' => $name,
'description' => strtok($package->getDescription(), "\r\n")
'description' => strtok($package->getDescription(), "\r\n"),
'length' => strlen($package->getPrettyName())
);
$maxPackageLength = max($maxPackageLength, strlen($package->getPrettyName()));
continue 2;
}
}
foreach ($packages as $details) {
$output->writeln($details['name'] .' <comment>:</comment> '. $details['description']);
$extraSpaces = $maxPackageLength - $details['length'];
$output->writeln($details['name'] . str_repeat(' ', $extraSpaces) .' <comment>:</comment> '. $details['description']);
}
}