Open Gelio opened 2 years ago
I've done some research and looks like this will be a bit more complex than I originally thought. Things we need to do:
Install (copy) https://github.com/urfave/cli/blob/master/autocomplete/bash_autocomplete as /etc/bash_completion.d/go-global-update
It would be great to offer a install-bash-autocomplete
command/script to make this step easier and not expect users to copy this file manually.
Set EnableBashCompletion
to true
in main.go
, according to https://github.com/urfave/cli/blob/master/docs/v2/manual.md#distribution-and-persistent-autocompletion
For the command arguments (go binary names), we would have to write a custom BashComplete
function to get the list of installed binaries
To make sure all of that works, it would be great to add some integration tests that try to invoke the completion with various arguments. This can be done by running go run main.go --generate-bash-completion
. We can provide existing arguments there too to simulate various inputs for completion. For example, to get a list of possible flags starting with d
:
11:39 $ go run main.go --d --generate-bash-completion
--debug
--dry-run
For ZSH, users would need to add a line to their config to enable completion: https://github.com/urfave/cli/blob/master/docs/v2/manual.md#zsh-support
For Powershell, same as for ZSH, they would need to edit the config: https://github.com/urfave/cli/blob/master/docs/v2/manual.md#powershell-support
It looks like they should work along with the custom bash completions
It would be nice to have bash completions for the supported flags and/or binaries passed as arguments.
Specifically, pressing tab for completions should lead to following output: