IBM / gWhisper

A gRPC CLI featuring reflection and tab-completion
Apache License 2.0
58 stars 15 forks source link

gwhisper binary returning completion script #105

Open ericboehmler opened 3 years ago

ericboehmler commented 3 years ago

Is your feature request related to a problem? Please describe. The CLI gh for github is having a nice feature. Called with a given parameter it is returning the completion script to the shell. This then can be evaluated into the bashrc or else. This makes changes in the completion script painless between version changes.

Describe the solution you'd like something like this:

gwhisper --completion=bash
returning the content of `complete.bash`

Then bashrc can evaluate it like this:

eval "$(gwhisper --completion=bash)"

Describe alternatives you've considered

Describe why you think this feature is useful for gWhisper users Changes in autocompletion are automatically reflected when the new version returns its respective completion script.

Additional context

rainerschoe commented 3 years ago

I think this is a good idea, however I do not yet completely understand the huge benefit of this approach in case of gWhisper:

The complete.bash file is basically only containing a redirection to gwhisper to return the actual completions. So it is very light weight. Since the initial open source release of gWhisper there was not a single change to those completion scripts.

It would be nice if shells would automatically have a standard way of querying a program for completions, but neither bash nor fish is doing this, so a complete.fish or complete.bash will still be needed and installed with this approach (with only one line though).

I think I will postpone this until the next change to those completion scripts is made and then implement it like you proposed.