Skip to content
Advertisement

Symfony Console tab completion

I have an application with a Symfony Console based CLI. The application does not use the Symfony framework, just the Symfony Console component.

When I execute

php app/myapp

I get the usual overview with the name, version, options and registered commands shown. Suppose I just have one command, called “displaykittens”. What I want to be able to do is

php app/myapp d <TAB>

And have it complete to

php app/myapp displaykittens

As is kinda expected in a modern unix environment. Unfortunately there appears to be no tab completion whatsoever. The Console Component itself provides an utility that allows doing something along these lines in commands themselves. That does not help me with getting tab completion for the commands though. Is this possible somehow?

Advertisement

Answer

The Application class of the Console component can be wrapped in a Shell class, provided by the same component. That provides some amount of auto completion.

According to people on the #symfony IRC on freenode, there is no way to have the console app provide autocompletion out of the box, since changes to the shell config need to be made.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement