1
0
Fork 0

[Command] Add suggests command

pull/4177/head
Gusakov Nikita 2014-03-17 15:26:19 +04:00 committed by Rob Bast
parent c43a39f733
commit f1af16984e
3 changed files with 71 additions and 0 deletions

View File

@ -294,6 +294,17 @@ in your browser.
* **--homepage (-H):** Open the homepage instead of the repository URL.
## suggests
To list all of vendors suggesting to install packages, you can use the `suggests` command.
$ php composer.phar suggests
### Options
* **--dev:** Show dev suggests.
## depends
The `depends` command tells you which other packages depend on a certain

View File

@ -0,0 +1,59 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Gusakov Nikita <dev@nkt.me>
*/
class SuggestsCommand extends Command
{
protected function configure()
{
$this
->setName('suggests')
->setDescription('Show packages suggests')
->setDefinition(array(
new InputOption('dev', null, InputOption::VALUE_NONE, 'Show dev suggests'),
))
->setHelp(<<<EOT
The <info>suggests</info> command show packages that suggesting to install other packages.
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$lockData = $this->getComposer()->getLocker()->getLockData();
$this->printSuggests($output, $lockData['packages']);
if ($input->getOption('dev')) {
$this->printSuggests($output, $lockData['packages-dev']);
}
}
private function printSuggests(OutputInterface $output, array $packages)
{
foreach ($packages as $package) {
if (isset($package['suggest'])) {
foreach ($package['suggest'] as $target => $reason) {
$output->writeln($package['name'].' suggests installing '.$target.' ('.$reason.')');
}
}
}
}
}

View File

@ -272,6 +272,7 @@ class Application extends BaseApplication
$commands[] = new Command\SearchCommand();
$commands[] = new Command\ValidateCommand();
$commands[] = new Command\ShowCommand();
$commands[] = new Command\SuggestsCommand();
$commands[] = new Command\RequireCommand();
$commands[] = new Command\DumpAutoloadCommand();
$commands[] = new Command\StatusCommand();