Fix Throbber Linebreak

This commit is contained in:
2026-05-04 18:34:50 +02:00
parent 66a3655133
commit b3b81bd7d6
+17
View File
@@ -35,6 +35,7 @@ type spinner struct {
on bool on bool
text string text string
msg []string msg []string
painted bool
} }
var spin = &spinner{ var spin = &spinner{
@@ -53,6 +54,19 @@ func (s *spinner) stop() {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
s.on = false s.on = false
if s.painted {
fmt.Fprint(os.Stderr, "\r\033[K\n")
s.painted = false
}
}
func (s *spinner) linebreak() {
s.mu.Lock()
defer s.mu.Unlock()
if s.on && s.painted {
fmt.Fprint(os.Stderr, "\r\033[K\n")
s.painted = false
}
} }
func (s *spinner) run(text string) { func (s *spinner) run(text string) {
@@ -66,6 +80,7 @@ func (s *spinner) run(text string) {
} }
msg := s.msg[i%len(s.msg)] msg := s.msg[i%len(s.msg)]
fmt.Fprintf(os.Stderr, "\r[%s] %s", msg, text) fmt.Fprintf(os.Stderr, "\r[%s] %s", msg, text)
s.painted = true
s.mu.Unlock() s.mu.Unlock()
i++ i++
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
@@ -224,6 +239,7 @@ func runBuildModule(ctx context) error {
} }
result, err := pipeline.BuildModuleWithProgress(p, func(message string) { result, err := pipeline.BuildModuleWithProgress(p, func(message string) {
spin.linebreak()
fmt.Fprintf(ctx.stdout, "[build-module] %s\n", message) fmt.Fprintf(ctx.stdout, "[build-module] %s\n", message)
}) })
if err != nil { if err != nil {
@@ -259,6 +275,7 @@ func runBuildHAKs(ctx context) error {
} }
progress := func(message string) { progress := func(message string) {
spin.linebreak()
fmt.Fprintf(ctx.stdout, "[build-haks] %s\n", message) fmt.Fprintf(ctx.stdout, "[build-haks] %s\n", message)
} }
var result pipeline.BuildResult var result pipeline.BuildResult