Show/Search command cleanups

main
Jordi Boggiano 12 years ago
parent 67eaae3842
commit 33c926c303

@ -61,11 +61,11 @@ EOT
foreach ($repos->getPackages() as $package) { foreach ($repos->getPackages() as $package) {
foreach ($tokens as $token) { foreach ($tokens as $token) {
if ($this->isUnmatchedPackage($package, $token)) { if (!$this->matchPackage($package, $token)) {
continue; continue;
} }
if (false !== ($pos = strpos($package->getName(), $token))) { if (false !== ($pos = stripos($package->getName(), $token))) {
$name = substr($package->getPrettyName(), 0, $pos) $name = substr($package->getPrettyName(), 0, $pos)
. '<highlight>' . substr($package->getPrettyName(), $pos, strlen($token)) . '</highlight>' . '<highlight>' . substr($package->getPrettyName(), $pos, strlen($token)) . '</highlight>'
. substr($package->getPrettyName(), $pos + strlen($token)); . substr($package->getPrettyName(), $pos + strlen($token));
@ -92,11 +92,11 @@ EOT
* @param string $token * @param string $token
* @return boolean * @return boolean
*/ */
private function isUnmatchedPackage(PackageInterface $package, $token) private function matchPackage(PackageInterface $package, $token)
{ {
return (false === strpos($package->getName(), $token)) return (false !== stripos($package->getName(), $token))
&& (false === strpos(join(',',$package->getKeywords() ?: array()), $token)) || (false !== stripos(join(',', $package->getKeywords() ?: array()), $token))
&& (false === strpos($package->getDescription(), $token)) || (false !== stripos($package->getDescription(), $token))
; ;
} }
} }

@ -132,21 +132,26 @@ 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> : <comment>' . $package->getPrettyName(). '</comment> '.$package->getDescription()); $output->writeln('<info>name</info> : ' . $package->getPrettyName());
$output->writeln('<info>descrip.</info> : ' . $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>license</info> : ' . implode(', ', $package->getLicense()));
$output->writeln('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference())); $output->writeln('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
$output->writeln('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference())); $output->writeln('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
$output->writeln('<info>license</info> : ' . join(', ', $package->getLicense())); $output->writeln('<info>names</info> : ' . implode(', ', $package->getNames()));
if ($package->getAutoload()) { if ($package->getAutoload()) {
$output->writeln("\n<info>autoload</info>"); $output->writeln("\n<info>autoload</info>");
foreach ($package->getAutoload() as $type => $autoloads) { foreach ($package->getAutoload() as $type => $autoloads) {
$output->writeln('<comment>' . $type . '</comment>'); $output->writeln('<comment>' . $type . '</comment>');
foreach ($autoloads as $name => $path) { if ($type === 'psr-0') {
$output->writeln($name . ' : ' . ($path ?: '.')); foreach ($autoloads as $name => $path) {
$output->writeln(($name ?: '*') . ' => ' . ($path ?: '.'));
}
} elseif ($type === 'classmap') {
$output->writeln(implode(', ', $autoloads));
} }
} }
} }
@ -170,7 +175,7 @@ EOT
uasort($versions, 'version_compare'); uasort($versions, 'version_compare');
$versions = join(', ', array_keys(array_reverse($versions))); $versions = implode(', ', array_keys(array_reverse($versions)));
// highlight installed version // highlight installed version
if ($installedRepo->hasPackage($package)) { if ($installedRepo->hasPackage($package)) {

Loading…
Cancel
Save