1
0
Fork 0

added description to show command, searching in description aswell

pull/435/head
digitalkaoz 2012-03-10 21:55:23 +01:00
parent edf93f1fcc
commit 741a66e504
2 changed files with 19 additions and 3 deletions

View File

@ -18,6 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Repository\ComposerRepository; use Composer\Repository\ComposerRepository;
use Composer\Package\PackageInterface;
/** /**
* @author Robert Schönthal <seroscho@googlemail.com> * @author Robert Schönthal <seroscho@googlemail.com>
@ -60,7 +61,7 @@ EOT
foreach ($repos->getPackages() as $package) { foreach ($repos->getPackages() as $package) {
foreach ($tokens as $token) { foreach ($tokens as $token) {
if (false === ($pos = strpos($package->getName(), $token)) && (false === strpos(join(',',$package->getKeywords() ?: array()), $token))) { if ($this->isUnmatchedPackage($package, $token)) {
continue; continue;
} }
@ -83,4 +84,19 @@ EOT
$output->writeln($name .' <comment>:</comment> '. join(', ', $versions)); $output->writeln($name .' <comment>:</comment> '. join(', ', $versions));
} }
} }
/**
* tries to find a token within the name/keywords/description
*
* @param PackageInterface $package
* @param string $token
* @return boolean
*/
private function isUnmatchedPackage(PackageInterface $package, $token)
{
return (false === strpos($package->getName(), $token)) &&
(false === strpos(join(',',$package->getKeywords() ?: array()), $token)) &&
(false === strpos($package->getDescription(), $token))
;
}
} }

View File

@ -132,7 +132,7 @@ EOT
*/ */
protected function printMeta(InputInterface $input, OutputInterface $output, PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $repos) protected function printMeta(InputInterface $input, OutputInterface $output, PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $repos)
{ {
$output->writeln('<info>name</info> : ' . $package->getPrettyName()); $output->writeln('<info>name</info> : <comment>' . $package->getPrettyName(). '</comment> '.$package->getDescription());
$this->printVersions($input, $output, $package, $installedRepo, $repos); $this->printVersions($input, $output, $package, $installedRepo, $repos);
$output->writeln('<info>type</info> : ' . $package->getType()); $output->writeln('<info>type</info> : ' . $package->getType());
$output->writeln('<info>names</info> : ' . join(', ', $package->getNames())); $output->writeln('<info>names</info> : ' . join(', ', $package->getNames()));