diff --git a/cmd/completion.go b/cmd/completion.go index 4eacaba..41eaae4 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -59,13 +59,29 @@ PowerShell: Run: func(cmd *cobra.Command, args []string) { switch args[0] { case "bash": - rootCmd.GenBashCompletion(os.Stdout) + err := rootCmd.GenBashCompletion(os.Stdout) + if err != nil { + fmt.Println("Error generating bash completion:", err) + return + } case "zsh": - rootCmd.GenZshCompletion(os.Stdout) + err := rootCmd.GenZshCompletion(os.Stdout) + if err != nil { + fmt.Println("Error generating zsh completion:", err) + return + } case "fish": - rootCmd.GenFishCompletion(os.Stdout, true) + err := rootCmd.GenFishCompletion(os.Stdout, true) + if err != nil { + fmt.Println("Error generating fish completion:", err) + return + } case "powershell": - rootCmd.GenPowerShellCompletionWithDesc(os.Stdout) + err := rootCmd.GenPowerShellCompletionWithDesc(os.Stdout) + if err != nil { + fmt.Println("Error generating powershell completion:", err) + return + } } }, } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 711d52a..19f4be2 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "os" "os/exec" "path/filepath" @@ -264,7 +265,11 @@ func TestLoadConfig_Failure1(t *testing.T) { defer os.RemoveAll(tmpDir) // Change the working directory to the temporary directory - os.Chdir(tmpDir) + err = os.Chdir(tmpDir) + if err != nil { + fmt.Println("Error while changing working directory to the temporary directory:", err) + return + } // Try to load a non-existent config file _, err = LoadConfig("non_existent_file.json") if err == nil {