Skip to content

Commit 63dbbae

Browse files
adriaanzonfabpot
authored andcommitted
[Console] Add descriptions to Fish completion output
1 parent d0d0492 commit 63dbbae

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Completion/Output/FishCompletionOutput.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ class FishCompletionOutput implements CompletionOutputInterface
2121
{
2222
public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
2323
{
24-
$values = $suggestions->getValueSuggestions();
24+
$values = [];
25+
foreach ($suggestions->getValueSuggestions() as $value) {
26+
$values[] = $value->getValue().($value->getDescription() ? "\t".$value->getDescription() : '');
27+
}
2528
foreach ($suggestions->getOptionSuggestions() as $option) {
26-
$values[] = '--'.$option->getName();
29+
$values[] = '--'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
2730
if ($option->isNegatable()) {
28-
$values[] = '--no-'.$option->getName();
31+
$values[] = '--no-'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
2932
}
3033
}
3134
$output->write(implode("\n", $values));

Resources/completion.fish

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ function _sf_{{ COMMAND_NAME }}
1919

2020
set completecmd $completecmd "-c$c"
2121

22-
set sfcomplete ($completecmd)
23-
24-
for i in $sfcomplete
25-
echo $i
26-
end
22+
$completecmd
2723
end
2824

2925
complete -c '{{ COMMAND_NAME }}' -a '(_sf_{{ COMMAND_NAME }})' -f

Tests/Completion/Output/FishCompletionOutputTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public function getCompletionOutput(): CompletionOutputInterface
2323

2424
public function getExpectedOptionsOutput(): string
2525
{
26-
return "--option1\n--negatable\n--no-negatable";
26+
return "--option1\tFirst Option\n--negatable\tCan be negative\n--no-negatable\tCan be negative";
2727
}
2828

2929
public function getExpectedValuesOutput(): string
3030
{
31-
return "Green\nRed\nYellow";
31+
return "Green\tBeans are green\nRed\tRose are red\nYellow\tCanaries are yellow";
3232
}
3333
}

0 commit comments

Comments
 (0)