Allow show <package> <constraint> as well as a version
parent
e8c362c273
commit
e82cf6835e
|
@ -44,7 +44,7 @@ class ShowCommand extends Command
|
||||||
->setDescription('Show information about packages')
|
->setDescription('Show information about packages')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect'),
|
new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect'),
|
||||||
new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'),
|
new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
|
||||||
new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only'),
|
new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only'),
|
||||||
new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
|
new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
|
||||||
new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
|
new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
|
||||||
|
@ -228,8 +228,7 @@ EOT
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$constraint = null;
|
$constraint = null;
|
||||||
if ($version) {
|
if ($version) {
|
||||||
$version = $this->versionParser->normalize($version);
|
$constraint = $this->versionParser->parseConstraints($version);
|
||||||
$constraint = new VersionConstraint('=', $version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy = new DefaultPolicy();
|
$policy = new DefaultPolicy();
|
||||||
|
@ -237,6 +236,7 @@ EOT
|
||||||
$pool->addRepository($repos);
|
$pool->addRepository($repos);
|
||||||
|
|
||||||
$matchedPackage = null;
|
$matchedPackage = null;
|
||||||
|
$versions = array();
|
||||||
$matches = $pool->whatProvides($name, $constraint);
|
$matches = $pool->whatProvides($name, $constraint);
|
||||||
foreach ($matches as $index => $package) {
|
foreach ($matches as $index => $package) {
|
||||||
// skip providers/replacers
|
// skip providers/replacers
|
||||||
|
@ -250,6 +250,7 @@ EOT
|
||||||
$matchedPackage = $package;
|
$matchedPackage = $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$versions[$package->getPrettyVersion()] = $package->getVersion();
|
||||||
$matches[$index] = $package->getId();
|
$matches[$index] = $package->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,13 +259,6 @@ EOT
|
||||||
$matchedPackage = $pool->literalToPackage($prefered[0]);
|
$matchedPackage = $pool->literalToPackage($prefered[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build versions array
|
|
||||||
$versions = array();
|
|
||||||
foreach ($matches as $package) {
|
|
||||||
$package = $pool->literalToPackage($package);
|
|
||||||
$versions[$package->getPrettyVersion()] = $package->getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($matchedPackage, $versions);
|
return array($matchedPackage, $versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,12 +309,6 @@ EOT
|
||||||
*/
|
*/
|
||||||
protected function printVersions(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
|
protected function printVersions(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
|
||||||
{
|
{
|
||||||
if ($input->getArgument('version')) {
|
|
||||||
$output->writeln('<info>version</info> : ' . $package->getPrettyVersion());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uasort($versions, 'version_compare');
|
uasort($versions, 'version_compare');
|
||||||
$versions = array_keys(array_reverse($versions));
|
$versions = array_keys(array_reverse($versions));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue