From 9e1ed5a52f42be9dee499902e78a32bdef352477 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 11 May 2012 20:42:35 -0500 Subject: [PATCH] [Command] Modifying the output of SearchCommand to make evenly-spaced package names for readability of results --- src/Composer/Command/SearchCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index 659d70904..1b3ea7817 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -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'] .' : '. $details['description']); + $extraSpaces = $maxPackageLength - $details['length']; + $output->writeln($details['name'] . str_repeat(' ', $extraSpaces) .' : '. $details['description']); } }