8000 Zsh shell autocompletions by adhocore · Pull Request #43970 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Zsh shell autocompletions #43970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Fix style
  • Loading branch information
adhocore committed Nov 9, 2021
commit f6a960b1034a5e70e78962a73d6bca8b558a2a54
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
&& 'command' === $input->getCompletionName()
) {
$suggestions->suggestValues(array_filter(array_map(function (Command $command) use ($input) {
return $command->isHidden() ? null : $command->getName() . ($input->isShell('zsh') ? "\t".$command->getDescription() : '');
return $command->isHidden() ? null : $command->getName().($input->isShell('zsh') ? "\t".$command->getDescription() : '');
Copy link
Member
@GromNaN GromNaN Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing if shell is zsh seems very specific for this place.

We could use a DTO. The ZshCompletionOutput would format the value with its specificities. By implementing the __toString method, the BashCompletionOutput would not require any change.

namespace Symfony\Component\Console\Completion;

final class SuggestedValue {
    private $value;
    private $description;

    public function __construct(string $value, string $description = null) {
        $this->value = $value;
        $this->description = $description;
    }

    public function __toString(): string {
        return $this->value;
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe some abstraction to tell/handle if the shell supports description for autocompleted suggestion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would add complexity in all commands that implements completion. I'm not sure this is something we want.
Each command should set suggestions values, optionally with a description using this DTO.

}, $this->all())));

return;
Expand Down
0