Console autocompletion fails because of console info text


#1

Hi there,

I’m currently trying to get console autocompletion working.
During my research, I saw that there already exists an implementation for autocompletion (“CompletionCommand”), but I think it’s broken.

I tried to integrate https://github.com/bamarni/symfony-console-autocomplete instead but seems like it fails for the same reason.
Problem is that the console command always prepends the current store and environment to the console output:
Store: DE | Environment: development
Even if I run console list --format=xml, which results in invalid xml.

This information usually is helpful. But it would be great if you could add a flag to disable it if necessary.


#2

Hello, I have working solution.

If you want to use completion in devvm:

vendor/bin/console _completion --generate-hook >> ~/.zshrc
source ~/.zshrc

now vendor/bin/console [TAB] should display all command

if you want to use just “console”:
change last line in ~/.zshrc from “vendor/bin/console” to “console”

Manual for Mac users:

  1. http://davidalger.com/development/bash-completion-on-os-x-with-brew/
  2. vendor/bin/console _completion --generate-hook >> ~/.bash_profile
  3. source ~/.bash_profile

Good luck!


#3

Hi Stanislav,

thanks for your response.
Your solution basically works for me too, but the problem is, that the commands are not cached.
So every time I request the autocomplete, it’ll parse the command list again.

Because of that, the completion takes several seconds. That way I’m not faster than typing it myself. :slight_smile:


#4

OK, I see the issue. This is the string before xml “Store: DE | Environment: development” and it breaks xml parser.

To fix it quickly just comment
vendor/spryker/console/src/Spryker/Zed/Console/Communication/ConsoleBootstrap.php:146

//$output->writeln($this->getInfoText());

and again run symfony-autocomplete vendor/bin/console >> ~/.zshrc

It works for me. We will open the ticket for this issue.