+30
-4
cmd/gust/main.go
+30
-4
cmd/gust/main.go
···
1
1
package main
2
2
3
3
import (
4
+
"fmt"
4
5
"log"
5
6
"os"
6
7
"path/filepath"
7
8
8
9
tea "github.com/charmbracelet/bubbletea"
9
10
"github.com/fsnotify/fsnotify"
11
+
10
12
"tangled.sh/oppili.bsky.social/gust"
11
13
)
12
14
···
20
22
defer f.Close()
21
23
}
22
24
23
-
// Create new watcher
25
+
if len(os.Args) < 2 {
26
+
fmt.Println("Usage: gust [build|run|dump] [package path]")
27
+
os.Exit(1)
28
+
}
29
+
30
+
cmd := os.Args[1]
31
+
32
+
switch cmd {
33
+
case "dump":
34
+
gust.DefaultConfig().Dump()
35
+
return
36
+
case "build", "run":
37
+
pkg := "./"
38
+
if len(os.Args) >= 3 {
39
+
pkg = os.Args[2]
40
+
}
41
+
run(cmd, pkg)
42
+
default:
43
+
fmt.Printf("Unknown command: %s\n", cmd)
44
+
os.Exit(1)
45
+
}
46
+
}
47
+
48
+
func run(mode, pkg string) {
24
49
w, err := fsnotify.NewWatcher()
25
50
if err != nil {
26
51
log.Println(err)
···
32
57
log.Println(err)
33
58
}
34
59
35
-
m := gust.NewModel(w)
60
+
cfg := gust.LoadConfig()
61
+
62
+
m := gust.NewModel(w, cfg, gust.WithMode(mode), gust.WithPackage(pkg))
36
63
37
64
p := tea.NewProgram(m, tea.WithAltScreen())
38
65
if _, err := p.Run(); err != nil {
···
42
69
}
43
70
44
71
func watchRecursively(watcher *fsnotify.Watcher, path string) error {
45
-
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
72
+
return filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
46
73
if err != nil {
47
74
return err
48
75
}
···
51
78
}
52
79
return nil
53
80
})
54
-
return err
55
81
}
+1
-1
config.go
+1
-1
config.go
+1
-1
flake.nix
+1
-1
flake.nix