Skip to content

Commit 024db03

Browse files
committed
feat(ux): add comprehensive error handling and feedback
- Editor launch: validate editor exists before launching, show clear error - Scan results: show helpful message when no repos found - Init command: display config location and saved settings - Editor check: 'e' key now validates editor and shows status - Better status messages throughout for user awareness
1 parent 57dcc97 commit 024db03

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

cmd/git-scope/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ func runInit() {
245245
log.Fatalf("Failed to create config: %v", err)
246246
}
247247

248-
fmt.Printf("\n✅ Config created at: %s\n", configPath)
249-
fmt.Println("\nRun 'git-scope' to launch the dashboard!")
248+
fmt.Printf("\n✅ Config created successfully!\n")
249+
fmt.Printf("\n📁 Location: %s\n", configPath)
250+
fmt.Println("\n📝 Configuration:")
251+
fmt.Println(" Directories to scan:")
252+
for _, d := range dirs {
253+
fmt.Printf(" • %s\n", d)
254+
}
255+
fmt.Printf(" Editor: %s\n", editor)
256+
fmt.Println("\n🚀 Run 'git-scope' to launch the dashboard!")
250257
}

internal/tui/update.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tui
22

33
import (
4+
"fmt"
45
"os/exec"
56

67
"github.com/charmbracelet/bubbles/textinput"
@@ -22,7 +23,15 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2223
m.repos = msg.repos
2324
m.state = StateReady
2425
m.updateTable()
25-
m.statusMsg = ""
26+
27+
// Show helpful message if no repos found
28+
if len(msg.repos) == 0 {
29+
m.statusMsg = fmt.Sprintf("⚠️ No git repos found in configured directories. Press 'r' to rescan or run 'git-scope init' to configure.")
30+
} else if msg.fromCache {
31+
m.statusMsg = fmt.Sprintf("✓ Loaded %d repos from cache", len(msg.repos))
32+
} else {
33+
m.statusMsg = fmt.Sprintf("✓ Found %d repos", len(msg.repos))
34+
}
2635
return m, nil
2736

2837
case scanErrorMsg:
@@ -31,6 +40,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
3140
return m, nil
3241

3342
case openEditorMsg:
43+
// Check if editor exists in PATH before trying to launch
44+
_, err := exec.LookPath(m.cfg.Editor)
45+
if err != nil {
46+
m.statusMsg = fmt.Sprintf("❌ Editor '%s' not found. Press 'e' to change editor or install it first.", m.cfg.Editor)
47+
return m, nil
48+
}
49+
3450
c := exec.Command(m.cfg.Editor, msg.path)
3551
return m, tea.ExecProcess(c, func(err error) tea.Msg {
3652
if err != nil {
@@ -146,7 +162,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
146162

147163
case "e":
148164
if m.state == StateReady {
149-
m.statusMsg = "Editor: " + m.cfg.Editor + " (change in ~/.config/git-scope/config.yml)"
165+
// Check if editor exists
166+
_, err := exec.LookPath(m.cfg.Editor)
167+
if err != nil {
168+
m.statusMsg = fmt.Sprintf("❌ Editor '%s' not found in PATH. Install it or edit ~/.config/git-scope/config.yml", m.cfg.Editor)
169+
} else {
170+
m.statusMsg = fmt.Sprintf("✓ Editor: %s (edit config at ~/.config/git-scope/config.yml)", m.cfg.Editor)
171+
}
150172
return m, nil
151173
}
152174
}

0 commit comments

Comments
 (0)