uselagoon / lagoon-cli

A CLI for Lagoon - Docker Build and Deploy System for Kubernetes
https://uselagoon.github.io/lagoon-cli
MIT License
24 stars 15 forks source link

Add shell completion #342

Open seanhamlin opened 5 months ago

seanhamlin commented 5 months ago

Is your feature request related to a problem? Please describe.

I would love shell completion for all Lagoon CLI commands and arguments.

Describe the solution you'd like

I believe Cobra has basic support for this

lagoon completion zsh > /tmp/lagoon.sh && source /tmp/lagoon.sh

However, this does not list the arguments from what I can tell.

It would also be nice to have documentation about this, perhaps around the installation instructions.

shreddedbacon commented 5 months ago

Huh, completion must have snuck in when I upgraded cobra a while back. Will need time to investigate, there may be limitation to what cobra provides, or how we do things that prevent it from working as intended.

shreddedbacon commented 5 months ago

It seems to do arguments for me with bash? perhaps a zsh thing?

tnelson-doghouse commented 4 months ago

If I type:

$ lagoon ad

...and then press tab, I get

-bash: _get_comp_words_by_ref: command not found

HTH,

shreddedbacon commented 4 months ago

I can't reproduce that behaviour, it works fine for me, so not sure where to even start here. Did your completion script get truncated, or are you sourcing it properly?

The shell completion scripts are not controlled by the lagoon-cli, but by cobra the underlying command library we use. So if there is a bug there, then I can't really help much.

smlx commented 4 months ago

@tnelson-doghouse Shell completion in bash relies on functions defined in the bash-completion library. I guess either you don't have bash-completion installed (that's what the package is called on Debian, not sure for other OS), or your .bashrc is missing this snippet.

tnelson-doghouse commented 4 months ago

Thanks @smlx ! Works for me now.

For the record, on Fedora I did:

sudo dnf install bash-completion

So it seems the remaining issues here are:

HTH,

mxr576 commented 1 day ago

+1 for better support (on ZSH)