From 202ca605591e9f326fcfcf490a6ffde1e31110e9 Mon Sep 17 00:00:00 2001 From: digitalkaoz Date: Fri, 9 Mar 2012 20:29:03 +0100 Subject: [PATCH 1/2] modified search listing (grouping packages) --- src/Composer/Command/SearchCommand.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index d01ebc1b4..a2006eaca 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -56,26 +56,26 @@ EOT } $tokens = array_map('strtolower', $input->getArgument('tokens')); + $packages = array(); + foreach ($repos->getPackages() as $package) { foreach ($tokens as $token) { if (false === ($pos = strpos($package->getName(), $token))) { continue; } - if ($platformRepo->hasPackage($package)) { - $type = 'platform: '; - } elseif ($installedRepo->hasPackage($package)) { - $type = 'installed: '; - } else { - $type = 'available: '; - } - $name = substr($package->getPrettyName(), 0, $pos) . '' . substr($package->getPrettyName(), $pos, strlen($token)) . '' . substr($package->getPrettyName(), $pos + strlen($token)); - $output->writeln($type . ': ' . $name . ' ' . $package->getPrettyVersion() . ''); + $version = $installedRepo->hasPackage($package) ? ''.$package->getPrettyVersion().'' : $package->getPrettyVersion(); + + $packages[$name][$package->getPrettyVersion()] = $version; continue 2; } } + + foreach ($packages as $name => $versions) { + $output->writeln($name .' : '. join(', ', $versions)); + } } } \ No newline at end of file From 38f866f1dd3475db30b4de6e4fc61a06c9a3426f Mon Sep 17 00:00:00 2001 From: digitalkaoz Date: Fri, 9 Mar 2012 22:03:26 +0100 Subject: [PATCH 2/2] fixes #373 aswell --- src/Composer/Command/SearchCommand.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index a2006eaca..7a25a2294 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -60,13 +60,18 @@ EOT foreach ($repos->getPackages() as $package) { foreach ($tokens as $token) { - if (false === ($pos = strpos($package->getName(), $token))) { + if (false === ($pos = strpos($package->getName(), $token)) && (false === strpos(join(',',$package->getKeywords() ?: array()), $token))) { continue; } - $name = substr($package->getPrettyName(), 0, $pos) - . '' . substr($package->getPrettyName(), $pos, strlen($token)) . '' - . substr($package->getPrettyName(), $pos + strlen($token)); + if (false !== ($pos = strpos($package->getName(), $token))) { + $name = substr($package->getPrettyName(), 0, $pos) + . '' . substr($package->getPrettyName(), $pos, strlen($token)) . '' + . substr($package->getPrettyName(), $pos + strlen($token)); + } else { + $name = $package->getPrettyName(); + } + $version = $installedRepo->hasPackage($package) ? ''.$package->getPrettyVersion().'' : $package->getPrettyVersion(); $packages[$name][$package->getPrettyVersion()] = $version;