1package main
2
3import (
4 "fmt"
5 "os"
6 "path"
7 "sync"
8
9 "github.com/MichaelMure/git-bug/commands"
10)
11
12func main() {
13 fmt.Println("Generating completion files ...")
14
15 tasks := map[string]func() error{
16 "Bash": genBash,
17 "Fish": genFish,
18 "PowerShell": genPowerShell,
19 "ZSH": genZsh,
20 }
21
22 var wg sync.WaitGroup
23 for name, f := range tasks {
24 wg.Add(1)
25 go func(name string, f func() error) {
26 defer wg.Done()
27 err := f()
28 if err != nil {
29 fmt.Printf(" - %s: %v\n", name, err)
30 return
31 }
32 fmt.Printf(" - %s: ok\n", name)
33 }(name, f)
34 }
35
36 wg.Wait()
37}
38
39func genBash() error {
40 cwd, _ := os.Getwd()
41 dir := path.Join(cwd, "misc", "bash_completion", "git-bug")
42 return commands.NewRootCommand().GenBashCompletionFile(dir)
43}
44
45func genFish() error {
46 cwd, _ := os.Getwd()
47 dir := path.Join(cwd, "misc", "fish_completion", "git-bug")
48 return commands.NewRootCommand().GenFishCompletionFile(dir, true)
49}
50
51func genPowerShell() error {
52 cwd, _ := os.Getwd()
53 filepath := path.Join(cwd, "misc", "powershell_completion", "git-bug")
54 return commands.NewRootCommand().GenPowerShellCompletionFile(filepath)
55}
56
57func genZsh() error {
58 cwd, _ := os.Getwd()
59 filepath := path.Join(cwd, "misc", "zsh_completion", "git-bug")
60 return commands.NewRootCommand().GenZshCompletionFile(filepath)
61}