asdf-community / asdf-hashicorp

HashiCorp plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
233 stars 54 forks source link

Feature request: autocompletion support #20

Open josemaia opened 3 years ago

josemaia commented 3 years ago

Is there any way to implement shell autocompletion for the hashicorp tools on install?

For example, in my machine I have complete -o nospace -C /usr/local/bin/vault vault on my .zshrc. From what I can see, if I migrate to an asdf-powered installation of vault I'd have no easy way to run this.

trallnag commented 3 years ago

Would be nice, but I think this is out of scope for asdf. At least for now.

There are issues regarding that open on the main repository of asdf. It's really difficult to support all kinds of shells and ways to enable auto completion. This is also why many tools like Terraform just opt to provide a command like terraform complete instead of setting it up automatically.

I install all my tools via a central Ansible playbook, so I handle the auto complete in separate tasks.

radditude commented 2 years ago

Indeed, this is a bit tricky! We could potentially call the tool's own autocomplete install command after install, but that seems prone to problems, not least because most tools support autocomplete for only bash and zsh. Not to mention the fact that there is no one common command for this across HashiCorp tooling:

One solution that comes to mind would be supporting an after install hook that the user provides - something like a .terraform-post-install file, which would allow the user to customize their autocomplete setup to their shell and a given tool.