-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
63 lines (52 loc) · 1.54 KB
/
main.go
File metadata and controls
63 lines (52 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2025 Fanis Hatzidakis
// Licensed under PolyForm Internal Use License 1.0.0 - see LICENCE.md
package main
import (
"errors"
"runtime"
"syscall"
"unsafe"
"github.com/fanis/claude-code-switcher/internal/config"
"github.com/fanis/claude-code-switcher/internal/gui"
"github.com/fanis/claude-code-switcher/internal/projects"
)
func utf16PtrFromString(s string) uintptr {
p, _ := syscall.UTF16PtrFromString(s)
return uintptr(unsafe.Pointer(p))
}
const appVersion = "0.3.1"
func main() {
// Win32 GUI operations must all happen on the same OS thread.
// Without this, Go may reschedule the goroutine to a different thread
// between window creation and message processing, crashing on first interaction.
runtime.LockOSThread()
// Load projects from Claude Code data
projectList, err := projects.LoadProjects()
if err != nil {
if errors.Is(err, projects.ErrNoProjects) {
showError("No Projects Found",
"No Claude Code projects were found.\n\n"+
"Please run Claude Code in a project directory first,\n"+
"then try again.")
} else {
showError("Error Loading Projects", err.Error())
}
return
}
// Load config (non-fatal if missing)
cfg, _ := config.Load()
// Run the GUI
gui.Run(projectList, appVersion, cfg)
}
func showError(title, message string) {
user32 := syscall.NewLazyDLL("user32.dll")
messageBox := user32.NewProc("MessageBoxW")
const MB_OK = 0x00000000
const MB_ICONERROR = 0x00000010
messageBox.Call(
0,
utf16PtrFromString(message),
utf16PtrFromString(title),
MB_OK|MB_ICONERROR,
)
}