diff options
author | Michael Muré <batolettre@gmail.com> | 2020-06-14 21:52:11 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-06-14 22:26:47 +0200 |
commit | 6352d6aa2338f47cd8b60631dec5f4161d9d92ec (patch) | |
tree | aac41ac96197ddcd33453ea4ab89e36e891d69a7 /misc | |
parent | 78f39c40778b31de63710cc022ff491c2e4586a7 (diff) | |
download | git-bug-6352d6aa2338f47cd8b60631dec5f4161d9d92ec.tar.gz |
generate docs and completion concurrently for a faster "make"
Diffstat (limited to 'misc')
-rw-r--r-- | misc/gen_bash_completion.go | 24 | ||||
-rw-r--r-- | misc/gen_completion.go | 61 | ||||
-rw-r--r-- | misc/gen_fish_completion.go | 24 | ||||
-rw-r--r-- | misc/gen_powershell_completion.go | 24 | ||||
-rw-r--r-- | misc/gen_zsh_completion.go | 24 |
5 files changed, 61 insertions, 96 deletions
diff --git a/misc/gen_bash_completion.go b/misc/gen_bash_completion.go deleted file mode 100644 index 2d5e400b..00000000 --- a/misc/gen_bash_completion.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build ignore - -package main - -import ( - "fmt" - "log" - "os" - "path" - - "github.com/MichaelMure/git-bug/commands" -) - -func main() { - cwd, _ := os.Getwd() - dir := path.Join(cwd, "misc", "bash_completion", "git-bug") - - fmt.Println("Generating Bash completion file ...") - - err := commands.RootCmd.GenBashCompletionFile(dir) - if err != nil { - log.Fatal(err) - } -} diff --git a/misc/gen_completion.go b/misc/gen_completion.go new file mode 100644 index 00000000..0ebb5eeb --- /dev/null +++ b/misc/gen_completion.go @@ -0,0 +1,61 @@ +package main + +import ( + "fmt" + "os" + "path" + "sync" + + "github.com/MichaelMure/git-bug/commands" +) + +func main() { + fmt.Println("Generating completion files ...") + + tasks := map[string]func() error{ + "Bash": genBash, + "Fish": genFish, + "PowerShell": genPowerShell, + "ZSH": genZsh, + } + + var wg sync.WaitGroup + for name, f := range tasks { + wg.Add(1) + go func(name string, f func() error) { + defer wg.Done() + err := f() + if err != nil { + fmt.Printf(" - %s: %v\n", name, err) + return + } + fmt.Printf(" - %s: ok\n", name) + }(name, f) + } + + wg.Wait() +} + +func genBash() error { + cwd, _ := os.Getwd() + dir := path.Join(cwd, "misc", "bash_completion", "git-bug") + return commands.RootCmd.GenBashCompletionFile(dir) +} + +func genFish() error { + cwd, _ := os.Getwd() + dir := path.Join(cwd, "misc", "fish_completion", "git-bug") + return commands.RootCmd.GenFishCompletionFile(dir, true) +} + +func genPowerShell() error { + cwd, _ := os.Getwd() + filepath := path.Join(cwd, "misc", "powershell_completion", "git-bug") + return commands.RootCmd.GenPowerShellCompletionFile(filepath) +} + +func genZsh() error { + cwd, _ := os.Getwd() + filepath := path.Join(cwd, "misc", "zsh_completion", "git-bug") + return commands.RootCmd.GenZshCompletionFile(filepath) +} diff --git a/misc/gen_fish_completion.go b/misc/gen_fish_completion.go deleted file mode 100644 index c274c05d..00000000 --- a/misc/gen_fish_completion.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build ignore - -package main - -import ( - "fmt" - "log" - "os" - "path" - - "github.com/MichaelMure/git-bug/commands" -) - -func main() { - cwd, _ := os.Getwd() - dir := path.Join(cwd, "misc", "fish_completion", "git-bug") - - fmt.Println("Generating Fish completion file ...") - - err := commands.RootCmd.GenFishCompletionFile(dir, true) - if err != nil { - log.Fatal(err) - } -} diff --git a/misc/gen_powershell_completion.go b/misc/gen_powershell_completion.go deleted file mode 100644 index c2766399..00000000 --- a/misc/gen_powershell_completion.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build ignore - -package main - -import ( - "fmt" - "log" - "os" - "path" - - "github.com/MichaelMure/git-bug/commands" -) - -func main() { - cwd, _ := os.Getwd() - filepath := path.Join(cwd, "misc", "powershell_completion", "git-bug") - - fmt.Println("Generating PowerShell completion file ...") - - err := commands.RootCmd.GenPowerShellCompletionFile(filepath) - if err != nil { - log.Fatal(err) - } -} diff --git a/misc/gen_zsh_completion.go b/misc/gen_zsh_completion.go deleted file mode 100644 index f80477d7..00000000 --- a/misc/gen_zsh_completion.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build ignore - -package main - -import ( - "fmt" - "log" - "os" - "path" - - "github.com/MichaelMure/git-bug/commands" -) - -func main() { - cwd, _ := os.Getwd() - filepath := path.Join(cwd, "misc", "zsh_completion", "git-bug") - - fmt.Println("Generating ZSH completion file ...") - - err := commands.RootCmd.GenZshCompletionFile(filepath) - if err != nil { - log.Fatal(err) - } -} |