diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 6ad8cae0f..52c44d6c6 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -43,8 +43,10 @@ class ShowCommand extends Command new InputArgument('version', InputArgument::OPTIONAL, 'Version to inspect'), new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed 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('self', 's', InputOption::VALUE_NONE, 'Show the root package information'), new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables display of dev-require packages.'), + new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'), )) ->setHelp(<<getOption('installed')) { $repos = $installedRepo = $getRepositories($this->getComposer(), $input->getOption('dev')); + } elseif ($input->getOption('available')) { + $installedRepo = $platformRepo; + $repos = new CompositeRepository(Factory::createDefaultRepositories($this->getIO())); } elseif ($composer = $this->getComposer(false)) { $localRepo = $getRepositories($composer, $input->getOption('dev')); $installedRepo = new CompositeRepository(array($localRepo, $platformRepo)); @@ -135,9 +140,13 @@ EOT } }, 'Composer\Package\CompletePackage'); + $tree = !$input->getOption('platform') && !$input->getOption('installed') && !$input->getOption('available'); + $indent = $tree ? ' ' : ''; foreach (array('platform:' => true, 'available:' => false, 'installed:' => true) as $type => $showVersion) { if (isset($packages[$type])) { - $output->writeln($type); + if ($tree) { + $output->writeln($type); + } ksort($packages[$type]); $nameLength = $versionLength = 0; @@ -150,10 +159,10 @@ EOT $width--; } - $writeVersion = $showVersion && ($nameLength + $versionLength + 3 <= $width); - $writeDescription = $nameLength + ($showVersion ? $versionLength : 0) + 24 <= $width; + $writeVersion = !$input->getOption('name-only') && $showVersion && ($nameLength + $versionLength + 3 <= $width); + $writeDescription = !$input->getOption('name-only') && ($nameLength + ($showVersion ? $versionLength : 0) + 24 <= $width); foreach ($packages[$type] as $package) { - $output->write(' ' . str_pad($package->getPrettyName(), $nameLength, ' '), false); + $output->write($indent . str_pad($package->getPrettyName(), $nameLength, ' '), false); if ($writeVersion) { $output->write(' ' . str_pad($this->versionParser->formatVersion($package), $versionLength, ' '), false); @@ -166,11 +175,12 @@ EOT $description = substr($description, 0, $remaining - 3) . '...'; } $output->write(' ' . $description); - } $output->writeln(''); } - $output->writeln(''); + if ($tree) { + $output->writeln(''); + } } } }