Open nenes25 opened 4 years ago
Autocompletion depend on the shell (bash, zsh, fish, ...) and require operation on the user's machine file. It might be a bit complicated to submit this to the PS project... Maybe not, I'm not used to contribute du Prestashop core.
Inspired by the zsh robo plugin. I managed to have autocompletion running 😄 (commands only, not arguments/parameters) with this : create file fop_compl.sh :
_fop_get_command_list () {
php72 ./bin/console --no-ansi | sed "1,/Available commands/d" | awk '/ ([a-z]+)/ { print $1 }'
}
_fop () {
compadd `_fop_get_command_list`
}
compdef _fop php72 ./bin/console
source fop_compl.sh
No change in fop_console code required. It works.
Note : For a daily usage, it should be linked/sourced in the ~/.zshrc (via plugin maybe). This example runs on my machine where I have multilple php binaries. You may need to replace
php72
withphp
.
However, using https://github.com/stecman/symfony-console-completion may be a better choice because of arguments completion. But it requires fop_console commands to implement special methods for arguments completion. (and also a user system modification (for sourcing)).
By the way, Symfony 5.4 & 6.0 will have autocompletion. https://symfony.com/blog/new-in-symfony-5-4-console-autocompletion
Check if it is possible to implement autocompletion Thanks to @SebSept idea : https://github.com/stecman/symfony-console-completion If not what about a pull request on PS projetct ?