Skip to content

Commit

Permalink
removes zsh completion since it does not work (fixes knative#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilien committed Oct 10, 2019
1 parent a2d1ef7 commit 9e45273
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
21 changes: 4 additions & 17 deletions pkg/kn/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,13 @@ import (
"github.com/spf13/cobra"
)

type CompletionFlags struct {
Zsh bool
}

func NewCompletionCommand(p *KnParams) *cobra.Command {
var completionFlags CompletionFlags

completionCmd := &cobra.Command{
return &cobra.Command{
Use: "completion",
Short: "Output shell completion code (default Bash)",
Hidden: true, // Don't show this in help listing.
Short: "Output shell completion code (Bash)",
Hidden: true, // Don't show this in help listing
Run: func(cmd *cobra.Command, args []string) {
if completionFlags.Zsh {
cmd.Root().GenZshCompletion(os.Stdout)
} else {
cmd.Root().GenBashCompletion(os.Stdout)
}
cmd.Root().GenBashCompletion(os.Stdout)
},
}

completionCmd.Flags().BoolVar(&completionFlags.Zsh, "zsh", false, "Generates completion code for Zsh shell.")
return completionCmd
}
11 changes: 1 addition & 10 deletions pkg/kn/commands/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestCompletion(t *testing.T) {
t.Run("creates a CompletionCommand", func(t *testing.T) {
setup()
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)
})

Expand All @@ -50,13 +50,4 @@ func TestCompletion(t *testing.T) {
completionCmd.Run(fakeRootCmd, []string{})
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) != "")
})
}

0 comments on commit 9e45273

Please sign in to comment.