background code checker for golang

model: graceful shutdown for subprocess

+36 -25
+1 -1
cmd/gust/main.go
··· 9 9 tea "github.com/charmbracelet/bubbletea" 10 10 "github.com/fsnotify/fsnotify" 11 11 12 - "tangled.sh/oppili.bsky.social/gust" 12 + "tangled.sh/oppi.li/gust" 13 13 ) 14 14 15 15 func main() {
+1 -1
go.mod
··· 1 - module tangled.sh/oppili.bsky.social/gust 1 + module tangled.sh/oppi.li/gust 2 2 3 3 go 1.23.8 4 4
+12 -8
model.go
··· 111 111 return nil 112 112 } 113 113 114 - // Stop stops the command and cleans up resources 115 114 func (p *CommandProcess) Stop() { 116 - p.cancel() 117 - if p.cmd != nil && p.cmd.Process != nil { 118 - p.cmd.Process.Kill() 115 + if p.cmd == nil || p.cmd.Process == nil { 116 + return 119 117 } 118 + 119 + p.cancel() 120 120 } 121 121 122 122 // CheckStatus returns the process state if available ··· 132 132 stdio []IoLine 133 133 134 134 messages []CompilerMessage 135 - fs Fs 136 - w *fsnotify.Watcher 137 - config Config 135 + extra []string // whatever was not parsed from the compiler output 136 + 137 + fs Fs 138 + w *fsnotify.Watcher 139 + config Config 138 140 139 141 status Status 140 142 systemErrors []error ··· 291 293 Line: msg.line, 292 294 Seq: msg.seq, 293 295 }) 294 - messages := Parse(m.stderr()) 296 + messages, extra := Parse(m.stderr()) 295 297 fs := Fs{} 296 298 if !m.config.Summarized { 297 299 fs = BuildFs(messages) 298 300 fs.PopulateContext(messages, m.config.Context) 299 301 } 300 302 m.messages = messages 303 + m.extra = extra 301 304 m.fs = fs 302 305 return m, m.checkStderr() 303 306 case processState: ··· 380 383 // Reset state 381 384 m.stdio = []IoLine{} 382 385 m.messages = nil 386 + m.extra = nil 383 387 m.fs = nil 384 388 385 389 // Create new process
+5 -2
parse.go
··· 28 28 Column string 29 29 } 30 30 31 - func Parse(output string) []CompilerMessage { 31 + func Parse(output string) ([]CompilerMessage, []string) { 32 32 var messages []CompilerMessage 33 33 var currentMultilineMsg *CompilerMessage 34 + var extra []string 34 35 35 36 scanner := bufio.NewScanner(strings.NewReader(output)) 36 37 for scanner.Scan() { ··· 41 42 } 42 43 43 44 if strings.HasPrefix(line, "#") { 45 + extra = append(extra, line) 44 46 continue 45 47 } 46 48 47 49 if strings.Contains(line, "panic:") { 50 + extra = append(extra, line) 48 51 continue 49 52 } 50 53 ··· 131 134 } 132 135 } 133 136 134 - return messages 137 + return messages, extra 135 138 } 136 139 137 140 func determineType(message string) string {
+3 -7
readme.md
··· 9 9 - useful error reporting: errors can be expanded/contracted, 10 10 they are sorted by priority, natively paged etc. 11 11 - good defaults: replacing `go ...` commands 12 - with `gust ...` should be enough to get started 12 + with `gust ...` should be sufficient to get started 13 13 - highly configurable UI, commands, keybinds etc. 14 14 15 15 ## gallery 16 16 17 - ![scrot1](https://cdn.oppi.li/h4g.png) 18 - 19 - ![scrot2](https://cdn.oppi.li/s1n.png) 20 - 21 - ![scrot3](https://cdn.oppi.li/keg.png) 22 - 17 + ![replacing go build with gust build](https://cdn.oppi.li/J9S.mp4) 23 18 24 19 ## todo 25 20 21 + - documentation 26 22 - support for `go test` 27 23 - live config reload
+14 -6
view.go
··· 37 37 b.WriteString(m.viewRun()) 38 38 } 39 39 40 + for _, o := range m.extra { 41 + b.WriteString(style.Error.Render(sign.System)) 42 + b.WriteString(" ") 43 + b.WriteString(o) 44 + b.WriteString("\n") 45 + } 46 + 40 47 for _, e := range m.systemErrors { 41 48 b.WriteString(style.Error.Render(sign.System)) 42 49 b.WriteString(" ") ··· 144 151 145 152 func (m Model) viewRun() string { 146 153 var b strings.Builder 147 - //style := m.config.Styles 148 154 149 155 if m.config.Stream == "stderr" { 150 156 b.WriteString(m.stderr()) ··· 271 277 272 278 var rightStatus strings.Builder 273 279 rightStatus.WriteString(" ") 274 - if m.config.Stream == "stderr" { 275 - rightStatus.WriteString(style.Stderr.Render("stderr")) 276 - } else { 277 - rightStatus.WriteString(style.Stdout.Render("stdout")) 280 + if m.config.Mode == "run" { 281 + if m.config.Stream == "stderr" { 282 + rightStatus.WriteString(style.Stderr.Render("stderr")) 283 + } else { 284 + rightStatus.WriteString(style.Stdout.Render("stdout")) 285 + } 286 + rightStatus.WriteString(style.Separator.Render(sign.Separator)) 278 287 } 279 - rightStatus.WriteString(style.Separator.Render(sign.Separator)) 280 288 rightStatus.WriteString(fmt.Sprintf("%3.f%%", m.viewport.ScrollPercent()*100)) 281 289 282 290 right := rightStatus.String()