Skip to content

Commit

Permalink
Add links to repo to show/outdated commands package lists, fixes comp…
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and emahorvat52 committed Jan 18, 2023
1 parent 0707692 commit ee4ba3f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Composer/Command/ShowCommand.php
Expand Up @@ -331,6 +331,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

// list packages
/** @var array<string, array<string, string|CompletePackageInterface>> $packages */
$packages = array();
$packageFilterRegex = null;
if (null !== $packageFilter) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 . '<href='.str_replace('>', '', $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);
}
Expand Down

0 comments on commit ee4ba3f

Please sign in to comment.