Skip to content

Commit

Permalink
fix completion bash
Browse files Browse the repository at this point in the history
Signed-off-by: guoxudong <[email protected]>
  • Loading branch information
sunny0826 committed Aug 5, 2020
1 parent 10949e5 commit a24677e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd
import (
zsh "github.com/rsteube/cobra-zsh-gen"
"github.com/spf13/cobra"
"log"
"os"
)

Expand All @@ -42,9 +43,15 @@ func (cc *CompletionCommand) Init() {
func (cc *CompletionCommand) runCompletion(command *cobra.Command, args []string) error {
complet := args[0]
if complet == "bash" {
cc.command.GenBashCompletion(os.Stdout)
err := command.Root().GenBashCompletion(os.Stdout)
if err != nil {
log.Fatal(err)
}
} else if complet == "zsh" {
zsh.Wrap(cc.command).GenZshCompletion(os.Stdout)
err := zsh.Wrap(cc.command).GenZshCompletion(os.Stdout)
if err != nil {
log.Fatal(err)
}
} else {
cc.command.PrintErrln("Parameter error! Please input bash or zsh")
}
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prashantv/gostub v1.0.0 h1:wTzvgO04xSS3gHuz6Vhuo0/kvWelyJxwNS0IRBPAwGY=
github.com/prashantv/gostub v1.0.0/go.mod h1:dP1v6T1QzyGJJKFocwAU0lSZKpfjstjH8TlhkEU0on0=
github.com/rsteube/cobra-zsh-gen v1.1.0 h1:o39gedEr6ziTpwUKNuwzG+Xk7kIbRpnxm48swTFGPVo=
github.com/rsteube/cobra-zsh-gen v1.1.0/go.mod h1:jbwt1uhI1Pd7fxUg+A3N1KQxUAJD8j0E0oLa3zdjhQY=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
Expand Down

0 comments on commit a24677e

Please sign in to comment.