Show/Search command cleanups
parent
67eaae3842
commit
33c926c303
|
@ -61,11 +61,11 @@ EOT
|
|||
|
||||
foreach ($repos->getPackages() as $package) {
|
||||
foreach ($tokens as $token) {
|
||||
if ($this->isUnmatchedPackage($package, $token)) {
|
||||
continue;
|
||||
if (!$this->matchPackage($package, $token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== ($pos = strpos($package->getName(), $token))) {
|
||||
if (false !== ($pos = stripos($package->getName(), $token))) {
|
||||
$name = substr($package->getPrettyName(), 0, $pos)
|
||||
. '<highlight>' . substr($package->getPrettyName(), $pos, strlen($token)) . '</highlight>'
|
||||
. substr($package->getPrettyName(), $pos + strlen($token));
|
||||
|
@ -92,11 +92,11 @@ EOT
|
|||
* @param string $token
|
||||
* @return boolean
|
||||
*/
|
||||
private function isUnmatchedPackage(PackageInterface $package, $token)
|
||||
private function matchPackage(PackageInterface $package, $token)
|
||||
{
|
||||
return (false === strpos($package->getName(), $token))
|
||||
&& (false === strpos(join(',',$package->getKeywords() ?: array()), $token))
|
||||
&& (false === strpos($package->getDescription(), $token))
|
||||
return (false !== stripos($package->getName(), $token))
|
||||
|| (false !== stripos(join(',', $package->getKeywords() ?: array()), $token))
|
||||
|| (false !== stripos($package->getDescription(), $token))
|
||||
;
|
||||
}
|
||||
}
|
|
@ -132,21 +132,26 @@ EOT
|
|||
*/
|
||||
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);
|
||||
$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>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()) {
|
||||
$output->writeln("\n<info>autoload</info>");
|
||||
foreach ($package->getAutoload() as $type => $autoloads) {
|
||||
$output->writeln('<comment>' . $type . '</comment>');
|
||||
|
||||
foreach ($autoloads as $name => $path) {
|
||||
$output->writeln($name . ' : ' . ($path ?: '.'));
|
||||
if ($type === 'psr-0') {
|
||||
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');
|
||||
|
||||
$versions = join(', ', array_keys(array_reverse($versions)));
|
||||
$versions = implode(', ', array_keys(array_reverse($versions)));
|
||||
|
||||
// highlight installed version
|
||||
if ($installedRepo->hasPackage($package)) {
|
||||
|
|
Loading…
Reference in New Issue