diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 3e14bd834d25..0666eddd2e8b 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -331,6 +331,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } // list packages + /** @var array> $packages */ $packages = array(); $packageFilterRegex = null; if (null !== $packageFilter) { @@ -442,6 +443,14 @@ protected function execute(InputInterface $input, OutputInterface $output) } $packageViewData['name'] = $package->getPrettyName(); + if ($format !== 'json' || true !== $input->getOption('name-only')) { + $packageViewData['homepage'] = $package->getHomepage(); + if (isset($package->getSupport()['source'])) { + $packageViewData['source'] = $package->getSupport()['source']; + } elseif (null !== $package->getSourceUrl()) { + $packageViewData['source'] = $package->getSourceUrl(); + } + } $nameLength = max($nameLength, strlen($package->getPrettyName())); if ($writeVersion) { $packageViewData['version'] = $package->getFullPrettyVersion(); @@ -533,7 +542,12 @@ protected function execute(InputInterface $input, OutputInterface $output) } foreach ($packages as $package) { - $io->write($indent . str_pad($package['name'], $nameLength, ' '), false); + $link = $package['source'] ?? $package['homepage'] ?? ''; + if ($link) { + $io->write($indent . '', '', $link).'>'.$package['name'].''. str_repeat(' ', $nameLength - strlen($package['name'])), false); + } else { + $io->write($indent . str_pad($package['name'], $nameLength, ' '), false); + } if (isset($package['version']) && $writeVersion) { $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false); }