1
0
Fork 0

limit suggestions to optional list of packages

pull/4177/head
Rob Bast 2015-06-23 21:29:48 +02:00
parent 760eeb0b03
commit 33f78b2ccc
1 changed files with 8 additions and 4 deletions

View File

@ -12,6 +12,7 @@
namespace Composer\Command; namespace Composer\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface;
@ -27,6 +28,7 @@ class SuggestsCommand extends Command
->setDescription('Show package suggestions') ->setDescription('Show package suggestions')
->setDefinition(array( ->setDefinition(array(
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'), new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
@ -50,14 +52,16 @@ EOT
$stderr = $output->getErrorOutput(); $stderr = $output->getErrorOutput();
} }
$packages = $lock['packages']; $list = $lock['packages'];
if (!$input->getOption('no-dev')) { if (!$input->getOption('no-dev')) {
$packages += $lock['packages-dev']; $list += $lock['packages-dev'];
} }
foreach ($packages as $package) { $packages = $input->getArgument('packages');
if (!empty($package['suggest'])) {
foreach ($list as $package) {
if (!empty($package['suggest']) && (empty($packages) || in_array($package['name'], $packages))) {
$stderr->writeln(sprintf('%s suggests:', $package['name'])); $stderr->writeln(sprintf('%s suggests:', $package['name']));
foreach ($package['suggest'] as $target => $reason) { foreach ($package['suggest'] as $target => $reason) {
if (empty($reason)) { if (empty($reason)) {