1
0
Fork 0

Refactor to use ArrayInput instead of StringInput

pull/5248/merge
Jordi Boggiano 2016-04-26 20:10:56 +01:00
parent 5c9c910240
commit 7def8cf6e5
1 changed files with 16 additions and 6 deletions

View File

@ -12,10 +12,9 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Util\ProcessExecutor;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -53,10 +52,21 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$args = array($input->getArgument('package') ? ProcessExecutor::escape($input->getArgument('package')) : ''); $args = array(
$args[] = $input->getOption('outdated') ? ProcessExecutor::escape('--outdated') : ''; 'show',
$args[] = $input->getOption('direct') ? ProcessExecutor::escape('--direct') : ''; '--latest' => true,
$input = new StringInput('show --latest '.implode(' ', $args)); );
if ($input->getOption('outdated')) {
$args['--outdated'] = true;
}
if ($input->getOption('direct')) {
$args['--direct'] = true;
}
if ($input->getArgument('package')) {
$args['package'] = $input->getArgument('package');
}
$input = new ArrayInput($args);
return $this->getApplication()->run($input, $output); return $this->getApplication()->run($input, $output);
} }