diff options
author | Michael Muré <batolettre@gmail.com> | 2020-07-28 20:24:24 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-07-28 20:24:24 +0200 |
commit | ae5c0967cec40a7dcf9804ff592a4d15f1b26569 (patch) | |
tree | 7c1ba7626fd8158be030876d44ba55daf465d694 /misc/gen_completion.go | |
parent | 51c887ff9dd4f2a5f65d2d3de57f8a7729b1010d (diff) | |
download | git-bug-ae5c0967cec40a7dcf9804ff592a4d15f1b26569.tar.gz |
commands: cleanup the command's usage to avoid warnings when generating the doc
Diffstat (limited to 'misc/gen_completion.go')
-rw-r--r-- | misc/gen_completion.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/misc/gen_completion.go b/misc/gen_completion.go index 80b89902..0bc546f7 100644 --- a/misc/gen_completion.go +++ b/misc/gen_completion.go @@ -6,13 +6,17 @@ import ( "path" "sync" + "github.com/spf13/cobra" + "github.com/MichaelMure/git-bug/commands" ) func main() { fmt.Println("Generating completion files ...") - tasks := map[string]func() error{ + root := commands.NewRootCommand() + + tasks := map[string]func(*cobra.Command) error{ "Bash": genBash, "Fish": genFish, "PowerShell": genPowerShell, @@ -22,9 +26,9 @@ func main() { var wg sync.WaitGroup for name, f := range tasks { wg.Add(1) - go func(name string, f func() error) { + go func(name string, f func(*cobra.Command) error) { defer wg.Done() - err := f() + err := f(root) if err != nil { fmt.Printf(" - %s: %v\n", name, err) return @@ -36,26 +40,26 @@ func main() { wg.Wait() } -func genBash() error { +func genBash(root *cobra.Command) error { cwd, _ := os.Getwd() dir := path.Join(cwd, "misc", "bash_completion", "git-bug") - return commands.NewRootCommand().GenBashCompletionFile(dir) + return root.GenBashCompletionFile(dir) } -func genFish() error { +func genFish(root *cobra.Command) error { cwd, _ := os.Getwd() dir := path.Join(cwd, "misc", "fish_completion", "git-bug") - return commands.NewRootCommand().GenFishCompletionFile(dir, true) + return root.GenFishCompletionFile(dir, true) } -func genPowerShell() error { +func genPowerShell(root *cobra.Command) error { cwd, _ := os.Getwd() filepath := path.Join(cwd, "misc", "powershell_completion", "git-bug") - return commands.NewRootCommand().GenPowerShellCompletionFile(filepath) + return root.GenPowerShellCompletionFile(filepath) } -func genZsh() error { +func genZsh(root *cobra.Command) error { cwd, _ := os.Getwd() filepath := path.Join(cwd, "misc", "zsh_completion", "git-bug") - return commands.NewRootCommand().GenZshCompletionFile(filepath) + return root.GenZshCompletionFile(filepath) } |