From e0edd882c5e1133c5bf227ffba9141856dd9140d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 29 Jun 2012 11:13:49 +0200 Subject: [PATCH] Add --self flag to composer show to see the root package info --- src/Composer/Command/ShowCommand.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 90737780d..7d8632588 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -19,6 +19,7 @@ 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\ArrayRepository; use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositoryInterface; @@ -39,6 +40,7 @@ class ShowCommand extends Command new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'), new InputOption('installed', null, InputOption::VALUE_NONE, 'List installed 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(<<getOption('platform')) { + if ($input->getOption('self')) { + $package = $this->getComposer(false)->getPackage(); + $repos = $installedRepo = new ArrayRepository(array($package)); + } elseif ($input->getOption('platform')) { $repos = $installedRepo = $platformRepo; } elseif ($input->getOption('installed')) { $composer = $this->getComposer(); @@ -70,8 +75,10 @@ EOT } // show single package or single version - if ($input->getArgument('package')) { - $package = $this->getPackage($input, $output, $installedRepo, $repos); + if ($input->getArgument('package') || !empty($package)) { + if (empty($package)) { + $package = $this->getPackage($input, $output, $installedRepo, $repos); + } if (!$package) { throw new \InvalidArgumentException('Package '.$input->getArgument('package').' not found'); }