aboutsummaryrefslogtreecommitdiffstats
path: root/misc/gen_completion.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-03-12 12:50:52 +0100
committerMichael Muré <batolettre@gmail.com>2022-05-01 10:54:13 +0200
commitf25690db47b110bcd0617d69cb0a35967313753c (patch)
treea774314ecce14d797915b0c8101be9efef316c9c /misc/gen_completion.go
parentbc6ba02bd84fc3bd86c61e89c16c400dfef01623 (diff)
downloadgit-bug-f25690db47b110bcd0617d69cb0a35967313753c.tar.gz
completion: use the correct GenBashCompletionV2 instead of the legacy function
Diffstat (limited to 'misc/gen_completion.go')
-rw-r--r--misc/gen_completion.go36
1 files changed, 30 insertions, 6 deletions
diff --git a/misc/gen_completion.go b/misc/gen_completion.go
index c073e67e..fc0f1f68 100644
--- a/misc/gen_completion.go
+++ b/misc/gen_completion.go
@@ -40,25 +40,49 @@ func main() {
}
func genBash(root *cobra.Command) error {
- cwd, _ := os.Getwd()
- dir := filepath.Join(cwd, "misc", "bash_completion", "git-bug")
- return root.GenBashCompletionFile(dir)
+ cwd, err := os.Getwd()
+ if err != nil {
+ return err
+ }
+ f, err := os.Create(filepath.Join(cwd, "misc", "bash_completion", "git-bug"))
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ // Custom bash code to connect the git completion for "git bug" to the
+ // git-bug completion for "git-bug"
+ _, err = f.WriteString(`#TODO: completion code to map "git bug" to "git-bug"`)
+ if err != nil {
+ return err
+ }
+
+ return root.GenBashCompletionV2(f, true)
}
func genFish(root *cobra.Command) error {
- cwd, _ := os.Getwd()
+ cwd, err := os.Getwd()
+ if err != nil {
+ return err
+ }
dir := filepath.Join(cwd, "misc", "fish_completion", "git-bug")
return root.GenFishCompletionFile(dir, true)
}
func genPowerShell(root *cobra.Command) error {
- cwd, _ := os.Getwd()
+ cwd, err := os.Getwd()
+ if err != nil {
+ return err
+ }
path := filepath.Join(cwd, "misc", "powershell_completion", "git-bug")
return root.GenPowerShellCompletionFile(path)
}
func genZsh(root *cobra.Command) error {
- cwd, _ := os.Getwd()
+ cwd, err := os.Getwd()
+ if err != nil {
+ return err
+ }
path := filepath.Join(cwd, "misc", "zsh_completion", "git-bug")
return root.GenZshCompletionFile(path)
}