Improve depends output, fixes #1459
parent
c80cb76b9b
commit
b51a4a7854
|
@ -25,8 +25,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
class DependsCommand extends Command
|
class DependsCommand extends Command
|
||||||
{
|
{
|
||||||
protected $linkTypes = array(
|
protected $linkTypes = array(
|
||||||
'require' => 'requires',
|
'require' => array('requires', 'requires'),
|
||||||
'require-dev' => 'devRequires',
|
'require-dev' => array('devRequires', 'requires (dev)'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
|
@ -65,7 +65,6 @@ EOT
|
||||||
|
|
||||||
$linkTypes = $this->linkTypes;
|
$linkTypes = $this->linkTypes;
|
||||||
|
|
||||||
$verbose = (bool) $input->getOption('verbose');
|
|
||||||
$types = array_map(function ($type) use ($linkTypes) {
|
$types = array_map(function ($type) use ($linkTypes) {
|
||||||
$type = rtrim($type, 's');
|
$type = rtrim($type, 's');
|
||||||
if (!isset($linkTypes[$type])) {
|
if (!isset($linkTypes[$type])) {
|
||||||
|
@ -75,19 +74,16 @@ EOT
|
||||||
return $type;
|
return $type;
|
||||||
}, $input->getOption('link-type'));
|
}, $input->getOption('link-type'));
|
||||||
|
|
||||||
$dependsOnPackages = false;
|
$messages = array();
|
||||||
foreach ($repos as $repo) {
|
foreach ($repos as $repo) {
|
||||||
$repo->filterPackages(function ($package) use ($needle, $types, $linkTypes, $output, $verbose, &$dependsOnPackages) {
|
$repo->filterPackages(function ($package) use ($needle, $types, $linkTypes, &$messages) {
|
||||||
static $outputPackages = array();
|
static $outputPackages = array();
|
||||||
|
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
foreach ($package->{'get'.$linkTypes[$type]}() as $link) {
|
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
||||||
if ($link->getTarget() === $needle) {
|
if ($link->getTarget() === $needle) {
|
||||||
$dependsOnPackages = true;
|
if (!isset($outputPackages[$package->getName()])) {
|
||||||
if ($verbose) {
|
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
|
||||||
$output->writeln($package->getPrettyName() . ' ' . $package->getPrettyVersion() . ' <info>' . $type . '</info> ' . $link->getPrettyConstraint());
|
|
||||||
} elseif (!isset($outputPackages[$package->getName()])) {
|
|
||||||
$output->writeln($package->getPrettyName());
|
|
||||||
$outputPackages[$package->getName()] = true;
|
$outputPackages[$package->getName()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +92,10 @@ EOT
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dependsOnPackages) {
|
if ($messages) {
|
||||||
|
sort($messages);
|
||||||
|
$output->writeln($messages);
|
||||||
|
} else {
|
||||||
$output->writeln('<info>There is no installed package depending on "'.$needle.'".</info>');
|
$output->writeln('<info>There is no installed package depending on "'.$needle.'".</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue