[Command] Add suggests command
parent
c43a39f733
commit
f1af16984e
|
@ -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
|
||||
|
|
|
@ -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.')');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue