OutdatedCommand.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Command;
  12. use Composer\Util\ProcessExecutor;
  13. use Symfony\Component\Console\Input\InputInterface;
  14. use Symfony\Component\Console\Input\InputArgument;
  15. use Symfony\Component\Console\Input\StringInput;
  16. use Symfony\Component\Console\Output\OutputInterface;
  17. /**
  18. * @author Jordi Boggiano <j.boggiano@seld.be>
  19. */
  20. class OutdatedCommand extends ShowCommand
  21. {
  22. protected function configure()
  23. {
  24. $this
  25. ->setName('outdated')
  26. ->setDescription('Shows a list of installed packages including their latest version.')
  27. ->setDefinition(array(
  28. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  29. ))
  30. ->setHelp(<<<EOT
  31. The outdated command is just a proxy for `composer show -l`
  32. The color coding for dependency versions is as such:
  33. - <info>green</info>: Dependency is in the latest version and is up to date.
  34. - <comment>yellow</comment>: Dependency has a new version available that includes backwards
  35. compatibility breaks according to semver, so upgrade when you can but it
  36. may involve work.
  37. - <highlight>red</highlight>: Dependency has a new version that is semver-compatible and you should upgrade it.
  38. EOT
  39. )
  40. ;
  41. }
  42. protected function execute(InputInterface $input, OutputInterface $output)
  43. {
  44. $pkg = $input->getArgument('package') ? ProcessExecutor::escape($input->getArgument('package')) : '';
  45. $input = new StringInput('show --latest '.$pkg);
  46. return $this->getApplication()->run($input, $output);
  47. }
  48. }