diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index 59c9231bf..0a4779ea5 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -19,6 +19,7 @@ use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\ComposerRepository; use Composer\Package\PackageInterface; +use Composer\Package\AliasPackage; /** * @author Robert Schönthal @@ -56,10 +57,14 @@ EOT $repos = new CompositeRepository(array($installedRepo, new ComposerRepository(array('url' => 'http://packagist.org')))); } - $tokens = array_map('strtolower', $input->getArgument('tokens')); + $tokens = $input->getArgument('tokens'); $packages = array(); foreach ($repos->getPackages() as $package) { + if ($package instanceof AliasPackage || isset($packages[$package->getName()])) { + continue; + } + foreach ($tokens as $token) { if (!$this->matchPackage($package, $token)) { continue; @@ -73,15 +78,16 @@ EOT $name = $package->getPrettyName(); } - $version = $installedRepo->hasPackage($package) ? ''.$package->getPrettyVersion().'' : $package->getPrettyVersion(); - - $packages[$name][$package->getPrettyVersion()] = $version; + $packages[$package->getName()] = array( + 'name' => $name, + 'description' => strtok($package->getDescription(), "\r\n") + ); continue 2; } } - foreach ($packages as $name => $versions) { - $output->writeln($name .' : '. join(', ', $versions)); + foreach ($packages as $details) { + $output->writeln($details['name'] .' : '. $details['description']); } } diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 7591ebfe2..c66972ca6 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -83,15 +83,32 @@ EOT } // list packages + $packages = array(); foreach ($repos->getPackages() as $package) { if ($platformRepo->hasPackage($package)) { - $type = 'platform: '; + $type = 'platform:'; } elseif ($installedRepo->hasPackage($package)) { - $type = 'installed: '; + $type = 'installed:'; } else { - $type = 'available: '; + $type = 'available:'; + } + if (isset($packages[$type][$package->getName()]) + && version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '>=') + ) { + continue; + } + $packages[$type][$package->getName()] = $package; + } + + foreach (array('platform:', 'available:', 'installed:') as $type) { + if (isset($packages[$type])) { + $output->writeln($type); + ksort($packages[$type]); + foreach ($packages[$type] as $package) { + $output->writeln(' '.$package->getPrettyName() .' : '. strtok($package->getDescription(), "\r\n")); + } + $output->writeln(''); } - $output->writeln($type . ' ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . ' (' . $package->getVersion() . ')'); } } diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 12d5a6aa8..495155276 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -36,14 +36,15 @@ class PlatformRepository extends ArrayRepository } $php = new MemoryPackage('php', $version, $prettyVersion); + $php->setDescription('The PHP interpreter'); parent::addPackage($php); - foreach (get_loaded_extensions() as $ext) { - if (in_array($ext, array('standard', 'Core'))) { + foreach (get_loaded_extensions() as $name) { + if (in_array($name, array('standard', 'Core'))) { continue; } - $reflExt = new \ReflectionExtension($ext); + $reflExt = new \ReflectionExtension($name); try { $prettyVersion = $reflExt->getVersion(); $version = $versionParser->normalize($prettyVersion); @@ -52,7 +53,8 @@ class PlatformRepository extends ArrayRepository $version = $versionParser->normalize($prettyVersion); } - $ext = new MemoryPackage('ext-'.strtolower($ext), $version, $prettyVersion); + $ext = new MemoryPackage('ext-'.$name, $version, $prettyVersion); + $ext->setDescription('The '.$name.' PHP extension'); parent::addPackage($ext); } }