GithubHelp home page GithubHelp logo

Comments (5)

chmouel avatar chmouel commented on May 29, 2024

/assign

Related :

switch args[0] {
case "bash":
return cmd.Root().GenBashCompletion(os.Stdout)
// TODO add zsh completion
// case "zsh":
// return cmd.Root().GenZshCompletion(os.Stdout)
// NOTE: cobra v0.0.3 zsh completion seems fail on zsh 5.5.1
}
return nil
},
}

Trying to enable it with :

@@ -34,21 +34,22 @@ Supported Shells:
   source bash_completion.sh
 `
 )
+
 func Command() *cobra.Command {
 	var cmd = &cobra.Command{
 		Use:       "completion SHELL",
 		Short:     "Prints shell completion scripts",
 		Long:      desc,
 		Args:      exactValidArgs(1),
-		ValidArgs: []string{"bash"},
+		ValidArgs: []string{"bash", "zsh"},
 		Example:   eg,
 		RunE: func(cmd *cobra.Command, args []string) error {
 			switch args[0] {
 			case "bash":
 				return cmd.Root().GenBashCompletion(os.Stdout)
-				// TODO add zsh completion
-				// case "zsh":
-				// return cmd.Root().GenZshCompletion(os.Stdout)
+			// TODO add zsh completion
+			case "zsh":
+				return cmd.Root().GenZshCompletion(os.Stdout)
 				// NOTE: cobra v0.0.3 zsh completion seems fail on zsh 5.5.1
 			}
 			return nil

and then inspect the generation from tkn completion zsh it seems that the completion generated is supposed to go in your fpath and cannot be evaluated directly. If I put in my fpath it would then work as per this screen recording :

https://asciinema.org/a/JbNcp2ftD0Kr2XwvFdsvIl3vF

Kubenertes is doing some nifty trick to be able to do some source <(kubectl completion zsh) with the tail and the head of the generated function :

https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/completion/completion.go#L305

We may want to adjust our completion system to do the same

from cli.

chmouel avatar chmouel commented on May 29, 2024

/kind enhancement

from cli.

chmouel avatar chmouel commented on May 29, 2024

Reading a bit more about this, kubectl is even sneakier, they won't use any of the stuff from cobra GenZSH completion they are doing it via the bashcominit bash completion to zsh extension, probably because it predate the support of zsh completion in cobra :

https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/completion/completion.go#L302

from cli.

vdemeester avatar vdemeester commented on May 29, 2024

/close

from cli.

tekton-robot avatar tekton-robot commented on May 29, 2024

@vdemeester: Closing this issue.

In response to this:

/close

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.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.