From 35240350eab9525d63361915c30d467edc108d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Fri, 20 Jul 2018 16:08:55 +0200 Subject: [PATCH] generate zsh completion --- .gitignore | 1 + doc/gen_zsh_completion.go | 21 +++++++++++++++++++++ doc/zsh_completion/git-bug | 20 ++++++++++++++++++++ git-bug.go | 1 + 4 files changed, 43 insertions(+) create mode 100644 doc/gen_zsh_completion.go create mode 100644 doc/zsh_completion/git-bug diff --git a/.gitignore b/.gitignore index 5af17954..e7f80491 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ git-bug !/doc/bash_completion/git-bug +!/doc/zsh_completion/git-bug diff --git a/doc/gen_zsh_completion.go b/doc/gen_zsh_completion.go new file mode 100644 index 00000000..319805fd --- /dev/null +++ b/doc/gen_zsh_completion.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "github.com/MichaelMure/git-bug/commands" + "log" + "os" + "path" +) + +func main() { + cwd, _ := os.Getwd() + filepath := path.Join(cwd, "doc", "zsh_completion", "git-bug") + + fmt.Println("Generating zsh completion file ...") + + err := commands.RootCmd.GenZshCompletionFile(filepath) + if err != nil { + log.Fatal(err) + } +} diff --git a/doc/zsh_completion/git-bug b/doc/zsh_completion/git-bug new file mode 100644 index 00000000..ce85f435 --- /dev/null +++ b/doc/zsh_completion/git-bug @@ -0,0 +1,20 @@ +#compdef git-bug + +_arguments \ + '1: :->level1' \ + '2: :_files' +case $state in + level1) + case $words[1] in + git-bug) + _arguments '1: :(close commands comment label ls new open pull push show webui)' + ;; + *) + _arguments '*: :_files' + ;; + esac + ;; + *) + _arguments '*: :_files' + ;; +esac diff --git a/git-bug.go b/git-bug.go index f17b1aae..bbe06227 100644 --- a/git-bug.go +++ b/git-bug.go @@ -2,6 +2,7 @@ //go:generate go run doc/gen_markdown.go //go:generate go run doc/gen_manpage.go //go:generate go run doc/gen_bash_completion.go +//go:generate go run doc/gen_zsh_completion.go package main