ZshCompletionOutput.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Completion\Output;
  11. use Symfony\Component\Console\Completion\CompletionSuggestions;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. /**
  14. * @author Jitendra A <adhocore@gmail.com>
  15. */
  16. class ZshCompletionOutput implements CompletionOutputInterface
  17. {
  18. /**
  19. * @param \Symfony\Component\Console\Completion\CompletionSuggestions $suggestions
  20. * @param \Symfony\Component\Console\Output\OutputInterface $output
  21. */
  22. public function write($suggestions, $output)
  23. {
  24. $values = [];
  25. foreach ($suggestions->getValueSuggestions() as $value) {
  26. $values[] = $value->getValue().($value->getDescription() ? "\t".$value->getDescription() : '');
  27. }
  28. foreach ($suggestions->getOptionSuggestions() as $option) {
  29. $values[] = '--'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
  30. if ($option->isNegatable()) {
  31. $values[] = '--no-'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
  32. }
  33. }
  34. $output->write(implode("\n", $values)."\n");
  35. }
  36. }