Kind: zsh completions can't be sourced

Created on 13 May 2019  路  10Comments  路  Source: kubernetes-sigs/kind

What happened:
Running source <(kind completion zsh) fails with the following error

_arguments:comparguments:325: can only be called from completion function
_arguments:comparguments:325: can only be called from completion function

What you expected to happen:
The completions to import and be available

How to reproduce it (as minimally and precisely as possible):
Run source <(kind completion zsh) in zsh

Anything else we need to know?:

Environment:

  • zsh version: zsh 5.7.1 (x86_64-apple-darwin18.2.0)
  • kind version: (use kind version): 0.3.0-alpha
  • Kubernetes version: (use kubectl version): 1.14
  • Docker version: (use docker info): 18.09.2
  • OS (e.g. from /etc/os-release): MacOS 10.14
help wanted kinbug

Most helpful comment

馃憢

I added the autocompletion subcommand.

If you run kind completion

```
Outputs kind shell completion for the given shell (bash or zsh)
This depends on the bash-completion binary. Example installation instructions:

for bash users

$ kind completion bash > ~/.kind-completion
$ source ~/.kind-completion

for zsh users

% kind completion zsh > /usr/local/share/zsh/site-functions/_kind
% autoload -U compinit && compinit

Additionally, you may want to output the completion to a file and source in your .bashrc
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2
```

There's a PR in spf13/cobra https://github.com/spf13/cobra/pull/887 which lets you source autocompletion in zsh directly like bash but that hasn't been merged yet

All 10 comments

hmm, I wonder if this is a bug upstream in cobra, we are generating these with that library
https://github.com/spf13/cobra

/help

@BenTheElder:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Did this work before? As afaik you don't source completions (as in bash) but instead add the folders containing them to fpath: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#telling-zsh-which-function-to-use-for-completing-a-command

e.g:
kind completion zsh > /somedir/_kind (once to generate it)
and in .zshrc

fpath=(/somedir $fpath)`
# and something like this (normally done by plugin managers - ideally only once for performance)
autoload -Uz compinit && \
   compinit -C

馃憢

I added the autocompletion subcommand.

If you run kind completion

```
Outputs kind shell completion for the given shell (bash or zsh)
This depends on the bash-completion binary. Example installation instructions:

for bash users

$ kind completion bash > ~/.kind-completion
$ source ~/.kind-completion

for zsh users

% kind completion zsh > /usr/local/share/zsh/site-functions/_kind
% autoload -U compinit && compinit

Additionally, you may want to output the completion to a file and source in your .bashrc
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2
```

There's a PR in spf13/cobra https://github.com/spf13/cobra/pull/887 which lets you source autocompletion in zsh directly like bash but that hasn't been merged yet

Thanks @epk ! :-)

/assign

The upstream PR was closed.
I'm not a zsh user, but it looks like you should be using the instructions in kind completion rather than doing a source <(kind completion zsh).

ref: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#telling-zsh-which-function-to-use-for-completing-a-command

IMO it looks like we should probably encourage installing the completion script output instead, which kind completion currently does.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anjiawei1991 picture anjiawei1991  路  34Comments

nicks picture nicks  路  31Comments

neolit123 picture neolit123  路  62Comments

nilebox picture nilebox  路  40Comments

mitar picture mitar  路  49Comments