Add --self flag to composer show to see the root package info

main
Jordi Boggiano 12 years ago
parent fa982a99c8
commit e0edd882c5

@ -19,6 +19,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Composer\Repository\ArrayRepository;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
@ -39,6 +40,7 @@ class ShowCommand extends Command
new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'), new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'),
new InputOption('installed', null, InputOption::VALUE_NONE, 'List installed packages only'), new InputOption('installed', null, InputOption::VALUE_NONE, 'List installed packages only'),
new InputOption('platform', null, InputOption::VALUE_NONE, 'List platform packages only'), new InputOption('platform', null, InputOption::VALUE_NONE, 'List platform packages only'),
new InputOption('self', null, InputOption::VALUE_NONE, 'Show the root package information'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
The show command displays detailed information about a package, or The show command displays detailed information about a package, or
@ -53,7 +55,10 @@ EOT
{ {
// init repos // init repos
$platformRepo = new PlatformRepository; $platformRepo = new PlatformRepository;
if ($input->getOption('platform')) { if ($input->getOption('self')) {
$package = $this->getComposer(false)->getPackage();
$repos = $installedRepo = new ArrayRepository(array($package));
} elseif ($input->getOption('platform')) {
$repos = $installedRepo = $platformRepo; $repos = $installedRepo = $platformRepo;
} elseif ($input->getOption('installed')) { } elseif ($input->getOption('installed')) {
$composer = $this->getComposer(); $composer = $this->getComposer();
@ -70,8 +75,10 @@ EOT
} }
// show single package or single version // show single package or single version
if ($input->getArgument('package')) { if ($input->getArgument('package') || !empty($package)) {
$package = $this->getPackage($input, $output, $installedRepo, $repos); if (empty($package)) {
$package = $this->getPackage($input, $output, $installedRepo, $repos);
}
if (!$package) { if (!$package) {
throw new \InvalidArgumentException('Package '.$input->getArgument('package').' not found'); throw new \InvalidArgumentException('Package '.$input->getArgument('package').' not found');
} }

Loading…
Cancel
Save