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

Added weaver completion bash completion command. #385

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mwhittaker
Copy link
Member

This PR introduces a weaver completion command that spits out a bash completion script that enables tab completion for the weaver command. For example:

$ weaver <tab><tab>
generate   gke        gke-local  multi      single     ssh        version
$ weaver single <tab><tab>
dashboard  deploy     help       metrics    profile    purge      status     version
$ weaver single p<tab><tab>
profile  purge

To enable the tab completion, you run source <(weaver completion). This mirrors kubectl completion bash. Source the file in your ~/.bashrc if you always want it to be enabled.

I added weaver completion selfishly, as I thought it was useful. If others find it useful, we can advertise it to users. There is a bit of overhead in updating it whenever commands change, and the gke commands could be stale, so it would require work to be more robust. Also happy to leave this out of the repo and have it privately for myself.

@mwhittaker mwhittaker self-assigned this Jun 9, 2023
This PR introduces a `weaver completion` command that spits out a bash
completion script that enables tab completion for the weaver command.
For example:

```bash
$ weaver <tab><tab>
generate   gke        gke-local  multi      single     ssh        version
$ weaver single <tab><tab>
dashboard  deploy     help       metrics    profile    purge      status     version
$ weaver single p<tab><tab>
profile  purge
```

To enable the tab completion, you run `source <(weaver completion)`.
This mirrors [`kubectl completion bash`][3]. Source the file in your
~/.bashrc if you always want it to be enabled.

I added `weaver completion` selfishly, as I thought it was useful. If
others find it useful, we can advertise it to users.

[3]: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-autocomplete
subcommands["single"]="dashboard deploy help metrics profile purge status version"
subcommands["multi"]="dashboard deploy help logs metrics profile purge status version"
subcommands["ssh"]="dashboard deploy help logs version"
subcommands["gke"]="dashboard deploy help kill logs profile status version"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice, Michael!

Is there any way to defer to weaver-gke and weaver-gke-local executables for completion on those? This will also help with other deployer commands.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Oh great point. Let me do some research into that.

@mwhittaker mwhittaker marked this pull request as draft July 5, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants