|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Console\Completion\Output;
|
13 | 13 |
|
14 |
| -use Symfony\Component\Console\Completion\CompletionInput; |
15 | 14 | use Symfony\Component\Console\Completion\CompletionSuggestions;
|
16 | 15 | use Symfony\Component\Console\Output\OutputInterface;
|
17 | 16 |
|
|
20 | 19 | */
|
21 | 20 | class BashCompletionOutput implements CompletionOutputInterface
|
22 | 21 | {
|
23 |
| - public function write(CompletionSuggestions $suggestions, CompletionInput $input, OutputInterface $output): void |
| 22 | + public function write(CompletionSuggestions $suggestions, OutputInterface $output): void |
24 | 23 | {
|
25 |
| - $options = []; |
| 24 | + $options = $suggestions->getValueSuggestions(); |
26 | 25 | foreach ($suggestions->getOptionSuggestions() as $option) {
|
27 | 26 | $options[] = '--'.$option->getName();
|
28 | 27 | }
|
29 |
| - $output->write(implode(' ', $options)); |
30 |
| - |
31 |
| - // add quotes to the suggestion if current value starts with a quote |
32 |
| - $completionValue = $input->getCompletionValue(); |
33 |
| - $quote = in_array($completionValue[0] ?? null, ['"', '\''], true) ? $completionValue[0] : null; |
34 |
| - |
35 |
| - $values = array_map(function ($value) use ($completionValue, $quote) { |
36 |
| - if (null !== $quote) { |
37 |
| - $value = $quote . $value . $quote; |
38 |
| - } elseif (str_contains($value, '\\')) { |
39 |
| - // without quote, more escaping is necessary |
40 |
| - $value = str_replace('\\', '\\\\', $value); |
41 |
| - } |
42 |
| - |
43 |
| - return escapeshellarg($value); |
44 |
| - }, $suggestions->getValueSuggestions()); |
45 |
| - |
46 |
| - $output->writeln(implode(' ', $values)); |
| 28 | + $output->writeln(implode("\n", $options)); |
47 | 29 | }
|
48 | 30 | }
|
0 commit comments