Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
vendor
/
wp-cli
/
vendor
/
composer
/
composer
/
src
/
Composer
/
Command
/
File Content:
SearchCommand.php
<?php /* * This file is part of Composer. * * (c) Nils Adermann <naderman@naderman.de> * Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Composer\Command; use Composer\Factory; use Composer\Json\JsonFile; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositoryInterface; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; /** * @author Robert Schönthal <seroscho@googlemail.com> */ class SearchCommand extends BaseCommand { /** * @return void */ protected function configure() { $this ->setName('search') ->setDescription('Searches for packages.') ->setDefinition(array( new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'), new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'), new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'), new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'), new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'), )) ->setHelp( <<<EOT The search command searches for packages by its name <info>php composer.phar search symfony composer</info> Read more at https://getcomposer.org/doc/03-cli.md#search EOT ) ; } protected function execute(InputInterface $input, OutputInterface $output) { // init repos $platformRepo = new PlatformRepository; $io = $this->getIO(); $format = $input->getOption('format'); if (!in_array($format, array('text', 'json'))) { $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format)); return 1; } if (!($composer = $this->getComposer(false))) { $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins')); } $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $installedRepo = new CompositeRepository(array($localRepo, $platformRepo)); $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories())); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output); $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); $mode = RepositoryInterface::SEARCH_FULLTEXT; if ($input->getOption('only-name') === true) { if ($input->getOption('only-vendor') === true) { throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together'); } $mode = RepositoryInterface::SEARCH_NAME; } elseif ($input->getOption('only-vendor') === true) { $mode = RepositoryInterface::SEARCH_VENDOR; } $type = $input->getOption('type'); $query = implode(' ', $input->getArgument('tokens')); if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) { $query = preg_quote($query); } $results = $repos->search($query, $mode, $type); if ($results && $format === 'text') { $width = $this->getTerminalWidth(); $nameLength = 0; foreach ($results as $result) { $nameLength = max(strlen($result['name']), $nameLength); } $nameLength += 1; foreach ($results as $result) { $description = isset($result['description']) ? $result['description'] : ''; $warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : ''; $remaining = $width - $nameLength - strlen($warning) - 2; if (strlen($description) > $remaining) { $description = substr($description, 0, $remaining - 3) . '...'; } $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description); } } elseif ($format === 'json') { $io->write(JsonFile::encode($results)); } return 0; } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
AboutCommand.php
1308 bytes
0644
ArchiveCommand.php
7815 bytes
0644
BaseCommand.php
10355 bytes
0644
BaseDependencyCommand.php
9100 bytes
0644
CheckPlatformReqsCommand.php
8009 bytes
0644
ClearCacheCommand.php
2296 bytes
0644
ConfigCommand.php
35185 bytes
0644
CreateProjectCommand.php
24747 bytes
0644
DependsCommand.php
1820 bytes
0644
DiagnoseCommand.php
28887 bytes
0644
DumpAutoloadCommand.php
5285 bytes
0644
ExecCommand.php
3539 bytes
0644
FundCommand.php
5412 bytes
0644
GlobalCommand.php
4007 bytes
0644
HomeCommand.php
5652 bytes
0644
InitCommand.php
45986 bytes
0644
InstallCommand.php
7733 bytes
0644
LicensesCommand.php
7415 bytes
0644
OutdatedCommand.php
5084 bytes
0644
ProhibitsCommand.php
2006 bytes
0644
ReinstallCommand.php
8552 bytes
0644
RemoveCommand.php
14381 bytes
0644
RequireCommand.php
22863 bytes
0644
RunScriptCommand.php
5223 bytes
0644
ScriptAliasCommand.php
2199 bytes
0644
SearchCommand.php
4799 bytes
0644
SelfUpdateCommand.php
26293 bytes
0644
ShowCommand.php
55499 bytes
0644
StatusCommand.php
8495 bytes
0644
SuggestsCommand.php
4081 bytes
0644
UpdateCommand.php
16773 bytes
0644
ValidateCommand.php
11564 bytes
0644
N4ST4R_ID | Naxtarrr