Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab completion for plugin commands #1116

Closed
m67hoff opened this issue Apr 10, 2017 · 5 comments
Closed

tab completion for plugin commands #1116

m67hoff opened this issue Apr 10, 2017 · 5 comments

Comments

@m67hoff
Copy link

m67hoff commented Apr 10, 2017

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

@cf-gitbot
Copy link

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.

@dkoper
Copy link

dkoper commented Apr 11, 2017

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.

@m67hoff
Copy link
Author

m67hoff commented Apr 11, 2017

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)

@dkoper
Copy link

dkoper commented Apr 11, 2017

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.

@dkoper
Copy link

dkoper commented Jun 26, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants