tangled
alpha
login
or
join now
oppi.li
/
gust
6
fork
atom
background code checker for golang
6
fork
atom
overview
issues
2
pulls
pipelines
gust: introduce cli
oppi.li
11 months ago
4211d1fa
d5525055
+33
-6
4 changed files
expand all
collapse all
unified
split
.gitignore
cmd
gust
main.go
config.go
flake.nix
+1
.gitignore
···
1
1
*.log
2
2
*.txt
3
3
gust
4
4
+
!cmd/gust
4
5
.envrc
5
6
.direnv
6
7
result
+30
-4
cmd/gust/main.go
···
1
1
package main
2
2
3
3
import (
4
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
11
+
10
12
"tangled.sh/oppili.bsky.social/gust"
11
13
)
12
14
···
20
22
defer f.Close()
21
23
}
22
24
23
23
-
// Create new watcher
25
25
+
if len(os.Args) < 2 {
26
26
+
fmt.Println("Usage: gust [build|run|dump] [package path]")
27
27
+
os.Exit(1)
28
28
+
}
29
29
+
30
30
+
cmd := os.Args[1]
31
31
+
32
32
+
switch cmd {
33
33
+
case "dump":
34
34
+
gust.DefaultConfig().Dump()
35
35
+
return
36
36
+
case "build", "run":
37
37
+
pkg := "./"
38
38
+
if len(os.Args) >= 3 {
39
39
+
pkg = os.Args[2]
40
40
+
}
41
41
+
run(cmd, pkg)
42
42
+
default:
43
43
+
fmt.Printf("Unknown command: %s\n", cmd)
44
44
+
os.Exit(1)
45
45
+
}
46
46
+
}
47
47
+
48
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
35
-
m := gust.NewModel(w)
60
60
+
cfg := gust.LoadConfig()
61
61
+
62
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
45
-
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
72
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
54
-
return err
55
81
}
+1
-1
config.go
···
252
252
func LoadConfig() Config {
253
253
cfg := DefaultConfig()
254
254
255
255
-
if _, err := toml.DecodeFile("config.toml", &cfg); err != nil {
255
255
+
if _, err := toml.DecodeFile(".gust.toml", &cfg); err != nil {
256
256
fmt.Fprintf(os.Stderr, "%s", err.Error())
257
257
}
258
258
+1
-1
flake.nix
···
30
30
version = "0.1.0";
31
31
src = gitignoreSource ./.;
32
32
subPackages = ["cmd/gust"];
33
33
-
vendorHash = "sha256-0+WwkJj/ZovrTrhPL4aimmaBfEgaIEtTt6HYDWzUIFE=";
33
33
+
vendorHash = "sha256-BXjnNZMITu8uC/B5hFv41QRXtOv5tDMBRySU4dcyu6E=";
34
34
env.CGO_ENABLED = 0;
35
35
};
36
36
};