tab completion for plugin commands
m67hoff opened this issue · 5 comments
Hy
it seems tab completion for plugin commands is not working. Hope this can be fixed / added ?
Thanks for looking into this - Michael
Some details:
It seems that cf-cli is generating its own "tab completion"-wordlist when GO_FLAGS_COMPLETION
is set. (from /usr/local/etc/bash_completion.d/cf-cli:)
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
cf-cli itself knows about installed plugin commands (see cf -h -a)
...
INSTALLED PLUGIN COMMANDS:
delete-target Delete a saved target
save-target Save current target
set-target Set current target
targets List available targets
copy Copy current space artifacts to another space. Uses targets saved by 'Targets' plugin when copying to another Cloud Foundry target.
sync Synchronize a folder to a container directory.
top Displays top stats - by Kurt Kellner of ECS Team
...
However if run with GO_FLAGS_COMPLETION
e.g.:
GO_FLAGS_COMPLETION=1 cf s
The plugin commands are missing. So also (bash) tab completion can't work for plugins.
I'm running on the release:
cf version 6.26.0+9c9a261fd.2017-04-06
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/143412259
The labels on this github issue will be updated when the story is started.
The CLI uses the Goflags library for command argument parsing. It provides the bash command completion for us.
Unfortunately, Goflags only supports statically defined commands, so is not aware of the plugin commands which are read in when the CLI is started. We were able to get cf help
to display the plugin commands by basically overriding Goflags' built-in generated help page. We couldn't find a way to do that for bash completion.
I'm afraid plugins will need to provide their own completion scripts and setup instructions to support tab completion.
OK - I understand - and move back to a generated list with keyword is probably not an option.
( something like cf -h -a | tail -n +10 | ghead -n -12 | cut -d' ' -f4 | grep ^[a-z] | sort
would create a list of all commands for completing, but only on non-windows)
There is also the problem that we can't "inject" such a list into what Goflags generates when GO_FLAGS_COMPLETION=1
is set.
And Goflags also generates completions for flags of native commands, and even some arguments and option values. I'm not sure how complex that would be to implement in a bash completion file.
Closing as we have no plans to work on this. Feel free to share any solution that works for you with others in the CF community.