removes zsh completion since it does not work (fixes #426) (#439)

This commit is contained in:
dr.max 2019-10-23 00:43:27 -07:00 committed by Knative Prow Robot
parent f77c034c4a
commit 462973c51f
2 changed files with 5 additions and 27 deletions

View File

@ -20,26 +20,13 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
type CompletionFlags struct {
Zsh bool
}
func NewCompletionCommand(p *KnParams) *cobra.Command { func NewCompletionCommand(p *KnParams) *cobra.Command {
var completionFlags CompletionFlags return &cobra.Command{
completionCmd := &cobra.Command{
Use: "completion", Use: "completion",
Short: "Output shell completion code (default Bash)", Short: "Output shell completion code (Bash)",
Hidden: true, // Don't show this in help listing. Hidden: true, // Don't show this in help listing
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if completionFlags.Zsh { cmd.Root().GenBashCompletion(os.Stdout)
cmd.Root().GenZshCompletion(os.Stdout)
} else {
cmd.Root().GenBashCompletion(os.Stdout)
}
}, },
} }
completionCmd.Flags().BoolVar(&completionFlags.Zsh, "zsh", false, "Generates completion code for Zsh shell.")
return completionCmd
} }

View File

@ -38,7 +38,7 @@ func TestCompletion(t *testing.T) {
t.Run("creates a CompletionCommand", func(t *testing.T) { t.Run("creates a CompletionCommand", func(t *testing.T) {
setup() setup()
assert.Equal(t, completionCmd.Use, "completion") assert.Equal(t, completionCmd.Use, "completion")
assert.Equal(t, completionCmd.Short, "Output shell completion code (default Bash)") assert.Equal(t, completionCmd.Short, "Output shell completion code (Bash)")
assert.Assert(t, completionCmd.RunE == nil) assert.Assert(t, completionCmd.RunE == nil)
}) })
@ -50,13 +50,4 @@ func TestCompletion(t *testing.T) {
completionCmd.Run(fakeRootCmd, []string{}) completionCmd.Run(fakeRootCmd, []string{})
assert.Assert(t, ReadStdout(t) != "") assert.Assert(t, ReadStdout(t) != "")
}) })
t.Run("returns completion code for ZSH", func(t *testing.T) {
setup()
CaptureStdout(t)
defer ReleaseStdout(t)
completionCmd.Run(fakeRootCmd, []string{"--zsh"})
assert.Assert(t, ReadStdout(t) != "")
})
} }