From 929d7093644e4f6b83ef366b83b5b66be075736e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 8 Aug 2018 20:12:04 +0200 Subject: [PATCH] bash completion: thanks to @tst2005, make the completion works for "git bug " --- commands/root.go | 6 ++++++ misc/bash_completion/git-bug | 5 +++++ misc/gen_bash_completion.go | 16 ---------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/commands/root.go b/commands/root.go index be2581992186a63628466b9bb5bee9adeec41586..67f05ebf12c947d2af3fdbb03e50edace00cd8fd 100644 --- a/commands/root.go +++ b/commands/root.go @@ -35,6 +35,12 @@ It use the same internal storage so it doesn't pollute your project. As you woul PersistentPreRunE: loadRepo, DisableAutoGenTag: true, + + BashCompletionFunction: ` +_git_bug() { + __start_git-bug "$@" +} +`, } func Execute() { diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug index d8505868b8331716dedd035088efb7d559f6f256..bc8319987f64e6e13e814698128c4d1c010fd722 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -243,6 +243,11 @@ __git-bug_handle_word() __git-bug_handle_word } + +_git_bug() { + __start_git-bug "$@" +} + _git-bug_close() { last_command="git-bug_close" diff --git a/misc/gen_bash_completion.go b/misc/gen_bash_completion.go index 3a75b0f506794e4192d3d589b243457df3ac7562..8793556a5f46532be6b573861e6490a67c683c70 100644 --- a/misc/gen_bash_completion.go +++ b/misc/gen_bash_completion.go @@ -16,22 +16,6 @@ func main() { fmt.Println("Generating bash completion file ...") - //git := &cobra.Command{ - // Use: "git", - // BashCompletionFunction: "qsdhjlkqsdhlsd", - //} - // - //bug := &cobra.Command{ - // Use: "bug", - // BashCompletionFunction: "ZHZLDHKLZDHJKL", - //} - //git.AddCommand(bug) - - //for _, sub := range commands.RootCmd.Commands() { - // bug.AddCommand(sub) - //} - - //err := git.GenBashCompletionFile(filepath) err := commands.RootCmd.GenBashCompletionFile(filepath) if err != nil { log.Fatal(err)