kubernetes-sigs / cluster-api

Home for Cluster API, a subproject of sig-cluster-lifecycle
https://cluster-api.sigs.k8s.io
Apache License 2.0
3.58k stars 1.31k forks source link

clusterctl completion: Use native zsh completion instead #4090

Closed superbrothers closed 3 years ago

superbrothers commented 3 years ago

User Story

As a developer I would like to use native zsh completion instead of the bash-compatibility one for making it easier to maintain.

Detailed Description

The current zsh completion of clusterctl is achieved by replacing some of the bash completions. Only a limited number of developers can maintain it because it is difficult to understand how it works.

Since cobra has supported native zsh completion since v1.1, we can replace it with this and it will be much easier to maintain. In addition, we will be ready to provide complements to other shells such as fish in the future.

Anything else you would like to add:

The native zsh completion provided by cobra does not support the use of completion in the following method:

source <(clusterctl completion zsh)

Instead, we should do the following. clusterctl completion's help message suggests the above method is available and will require the user to make changes.

$ clusterctl completion zsh > "${fpath[1]}/_clusterctl"

/kind feature /area clusterctl

fabriziopandini commented 3 years ago

/milestone v0.4.0

vincepri commented 3 years ago

/priority important-longterm