1
0
Fork 0

Merge pull request #4970 from barryvdh/list-installed-default

Change default behavior of show/list to --installed by default
pull/4207/merge
Jordi Boggiano 2016-02-29 16:29:34 +00:00
commit b6b2635f42
1 changed files with 14 additions and 9 deletions

View File

@ -52,7 +52,8 @@ class ShowCommand extends BaseCommand
->setDefinition(array( ->setDefinition(array(
new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect'), new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect'),
new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'), new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only'), new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'), new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'), new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'), new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
@ -79,9 +80,13 @@ EOT
$composer = $this->getComposer(false); $composer = $this->getComposer(false);
$io = $this->getIO(); $io = $this->getIO();
if ($input->getOption('tree') && !$input->getOption('installed')) { if ($input->getOption('installed')) {
$io->writeError('The --tree (-t) option is only usable in combination with --installed (-i) or by passing a single package name to show, assuming -i'); $io->writeError('<warning>You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.</warning>');
$input->setOption('installed', true); }
if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
$io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
return;
} }
// init repos // init repos
@ -96,8 +101,6 @@ EOT
$repos = $installedRepo = new ArrayRepository(array($package)); $repos = $installedRepo = new ArrayRepository(array($package));
} elseif ($input->getOption('platform')) { } elseif ($input->getOption('platform')) {
$repos = $installedRepo = $platformRepo; $repos = $installedRepo = $platformRepo;
} elseif ($input->getOption('installed')) {
$repos = $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
} elseif ($input->getOption('available')) { } elseif ($input->getOption('available')) {
$installedRepo = $platformRepo; $installedRepo = $platformRepo;
if ($composer) { if ($composer) {
@ -107,15 +110,17 @@ EOT
$repos = new CompositeRepository($defaultRepos); $repos = new CompositeRepository($defaultRepos);
$io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos))); $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
} }
} elseif ($composer) { } elseif ($input->getOption('all') && $composer) {
$localRepo = $composer->getRepositoryManager()->getLocalRepository(); $localRepo = $composer->getRepositoryManager()->getLocalRepository();
$installedRepo = new CompositeRepository(array($localRepo, $platformRepo)); $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories())); $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
} else { } elseif ($input->getOption('all')) {
$defaultRepos = Factory::createDefaultRepositories($io); $defaultRepos = Factory::createDefaultRepositories($io);
$io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos))); $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
$installedRepo = $platformRepo; $installedRepo = $platformRepo;
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos)); $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
} else {
$repos = $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
} }
if ($composer) { if ($composer) {
@ -208,7 +213,7 @@ EOT
} }
} }
$showAllTypes = !$input->getOption('platform') && !$input->getOption('installed') && !$input->getOption('available'); $showAllTypes = $input->getOption('all');
$indent = $showAllTypes ? ' ' : ''; $indent = $showAllTypes ? ' ' : '';
foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) { foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) {
if (isset($packages[$type])) { if (isset($packages[$type])) {