platform CLI tool contains a large library of commands, and trying to list them each time you can’t quite remember the names or options can fill up your screen really fast. Tab-completion will be able to help us out here.
We want autocomplete support (press tab to get command and option suggestions) for the
platform CLI tool.
As it’s a
symfony component, these commands can be programmatically extracted in a standard way.
symfony-console-autocomplete tool does this for us.
Instructions here for OSX, the setup instructions are similar for other systems and shells
If you don’t have bash-completion installed by default, get that first.
brew on OSX. *nix sessions probably already have it.
brew install bash-completion
Add the startup line to your ~/.bash_profile like it advises.
Scripts found in
/usr/local/etc/bash_completion.d/ can support individual commands now.
composer global require bamarni/symfony-console-autocomplete
Now we can generate a dump of all symfony-console-based CLI commands, and use that dump to generate the autocomplete prompts.
Auto-generate autocomplete hints for
symfony-autocomplete platform --script-options=list > /usr/local/etc/bash_completion.d/platform
Restart your shell session (or at least
source ~/.bash_profile) and autocomplete should be available for platform cli now.
/usr/local/etc/bash_completion.d/will differ depending on your OS, version, and preferred shell. Alternate instructions for
zshetc are in the README. The only difference from the examples there is that we have to add
--script-options=listto extract the commands for
Pressing [TAB] part-way through entering
platform commands will now provide either autocompletion or a list of suggestions, for both commands and options to those commands.
$ platform pr[TAB] platform project: $ platform project:[TAB] clear-build-cache curl get list variable:delete variable:set create delete info set-remote variable:get $ platform project:l[TAB] platform project:list $ platform project:list --[TAB] --columns --help --my --no-header --quiet --reverse --title --version --format --host --no --pipe --refresh --sort --verbose --yes