From cfa79db2fa666a6eabfda9c8d6bf09c55218f27a Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Mon, 6 Oct 2025 00:22:30 +0530 Subject: [PATCH 1/4] fix #3 : improve error messages and user feedback Replace log.Fatal calls with pterm error displays for colored output --- cmd/cli/createMsg.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/cli/createMsg.go b/cmd/cli/createMsg.go index 63c8c26..bf585c7 100644 --- a/cmd/cli/createMsg.go +++ b/cmd/cli/createMsg.go @@ -1,7 +1,6 @@ package cmd import ( - "log" "os" "github.com/atotto/clipboard" @@ -23,7 +22,8 @@ func CreateCommitMsg () { // Validate COMMIT_LLM and required API keys useLLM,err := store.DefaultLLMKey() if err != nil { - log.Fatal(err) + pterm.Error.Printf("Error: %v\n", err) + os.Exit(1) } commitLLM := useLLM.LLM @@ -33,12 +33,14 @@ func CreateCommitMsg () { // Get current directory currentDir, err := os.Getwd() if err != nil { - log.Fatalf("Failed to get current directory: %v", err) + pterm.Error.Printf("Failed to get current directory: %v\n", err) + os.Exit(1) } // Check if current directory is a git repository if !git.IsRepository(currentDir) { - log.Fatalf("Current directory is not a Git repository: %s", currentDir) + pterm.Error.Printf("Current directory is not a Git repository: %s\n", currentDir) + os.Exit(1) } // Create a minimal config for the API @@ -54,7 +56,8 @@ func CreateCommitMsg () { // Get file statistics before fetching changes fileStats, err := stats.GetFileStatistics(&repoConfig) if err != nil { - log.Fatalf("Failed to get file statistics: %v", err) + pterm.Error.Printf("Failed to get file statistics: %v\n", err) + os.Exit(1) } // Display header @@ -76,7 +79,8 @@ func CreateCommitMsg () { // Get the changes changes, err := git.GetChanges(&repoConfig) if err != nil { - log.Fatalf("Failed to get Git changes: %v", err) + pterm.Error.Printf("Failed to get Git changes: %v\n", err) + os.Exit(1) } if len(changes) == 0 { @@ -91,7 +95,8 @@ func CreateCommitMsg () { WithSequence("⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"). Start("🤖 Generating commit message...") if err != nil { - log.Fatalf("Failed to start spinner: %v", err) + pterm.Error.Printf("Failed to start spinner: %v\n", err) + os.Exit(1) } var commitMsg string @@ -114,7 +119,8 @@ func CreateCommitMsg () { if err != nil { spinnerGenerating.Fail("Failed to generate commit message") - log.Fatalf("Error: %v", err) + pterm.Error.Printf("Error: %v\n", err) + os.Exit(1) } spinnerGenerating.Success("✅ Commit message generated successfully!") From d0482151d05a3a1da98bae6ccf8e103c0ad1975d Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Mon, 6 Oct 2025 00:29:13 +0530 Subject: [PATCH 2/4] fix #3 : improve API key error messages Add specific instructions for setting environment variables when API keys are missing --- cmd/cli/createMsg.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/cli/createMsg.go b/cmd/cli/createMsg.go index bf585c7..f453814 100644 --- a/cmd/cli/createMsg.go +++ b/cmd/cli/createMsg.go @@ -22,7 +22,7 @@ func CreateCommitMsg () { // Validate COMMIT_LLM and required API keys useLLM,err := store.DefaultLLMKey() if err != nil { - pterm.Error.Printf("Error: %v\n", err) + pterm.Error.Printf("No LLM configured. Run: commit llm setup\n") os.Exit(1) } @@ -64,7 +64,7 @@ func CreateCommitMsg () { pterm.DefaultHeader.WithFullWidth(). WithBackgroundStyle(pterm.NewStyle(pterm.BgDarkGray)). WithTextStyle(pterm.NewStyle(pterm.FgLightWhite)). - Println("🚀 Commit Message Generator") + Println("Commit Message Generator") pterm.Println() @@ -93,7 +93,7 @@ func CreateCommitMsg () { // Show generating spinner spinnerGenerating, err := pterm.DefaultSpinner. WithSequence("⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"). - Start("🤖 Generating commit message...") + Start("Generating commit message...") if err != nil { pterm.Error.Printf("Failed to start spinner: %v\n", err) os.Exit(1) @@ -119,7 +119,18 @@ func CreateCommitMsg () { if err != nil { spinnerGenerating.Fail("Failed to generate commit message") - pterm.Error.Printf("Error: %v\n", err) + switch commitLLM { + case "Gemini": + pterm.Error.Printf("Gemini API error. Check your GEMINI_API_KEY environment variable or run: commit llm setup\n") + case "OpenAI": + pterm.Error.Printf("OpenAI API error. Check your OPENAI_API_KEY environment variable or run: commit llm setup\n") + case "Claude": + pterm.Error.Printf("Claude API error. Check your CLAUDE_API_KEY environment variable or run: commit llm setup\n") + case "Grok": + pterm.Error.Printf("Grok API error. Check your GROK_API_KEY environment variable or run: commit llm setup\n") + default: + pterm.Error.Printf("LLM API error: %v\n", err) + } os.Exit(1) } From cff43cd0ea0983310dde3e77954b092f13a60c04 Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Mon, 6 Oct 2025 00:55:13 +0530 Subject: [PATCH 3/4] Fix #3 : add progress indicators showing LLM provider during generation Update spinner message to display which LLM (Gemini, OpenAI, Claude, Grok) is being used --- cmd/cli/createMsg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cli/createMsg.go b/cmd/cli/createMsg.go index f453814..bfedd2f 100644 --- a/cmd/cli/createMsg.go +++ b/cmd/cli/createMsg.go @@ -93,7 +93,7 @@ func CreateCommitMsg () { // Show generating spinner spinnerGenerating, err := pterm.DefaultSpinner. WithSequence("⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"). - Start("Generating commit message...") + Start("Generating commit message with " + commitLLM + "...") if err != nil { pterm.Error.Printf("Failed to start spinner: %v\n", err) os.Exit(1) From 533ee5e6fe780b127e23220bbc1c90bd68bfaca2 Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Mon, 6 Oct 2025 00:57:59 +0530 Subject: [PATCH 4/4] Fix #3 : add helpful tips when no Git changes are detected Display actionable guidance for staging changes, checking status, and verifying repository location --- cmd/cli/createMsg.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/cli/createMsg.go b/cmd/cli/createMsg.go index bfedd2f..7a24be3 100644 --- a/cmd/cli/createMsg.go +++ b/cmd/cli/createMsg.go @@ -73,6 +73,10 @@ func CreateCommitMsg () { if fileStats.TotalFiles == 0 { pterm.Warning.Println("No changes detected in the Git repository.") + pterm.Info.Println("Tips:") + pterm.Info.Println(" - Stage your changes with: git add .") + pterm.Info.Println(" - Check repository status with: git status") + pterm.Info.Println(" - Make sure you're in the correct Git repository") return } @@ -85,6 +89,10 @@ func CreateCommitMsg () { if len(changes) == 0 { pterm.Warning.Println("No changes detected in the Git repository.") + pterm.Info.Println("Tips:") + pterm.Info.Println(" - Stage your changes with: git add .") + pterm.Info.Println(" - Check repository status with: git status") + pterm.Info.Println(" - Make sure you're in the correct Git repository") return }