refactor: Analyzer to generalise

This commit is contained in:
abhisek
2025-05-14 18:56:58 +05:30
parent 8eace0c7f6
commit 4dcf7cad0b
7 changed files with 114 additions and 51 deletions
+9 -1
View File
@@ -8,6 +8,14 @@ import (
var spinnerChan chan bool
func StartSpinner(msg string) {
StartSpinnerWithColor(msg, Colors.Normal)
}
func StartSpinnerWithColor(msg string, c ColorFn) {
if c == nil {
c = Colors.Normal
}
style := `⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`
frames := []rune(style)
length := len(frames)
@@ -24,7 +32,7 @@ func StartSpinner(msg string) {
ticker.Stop()
return
case <-ticker.C:
fmt.Printf("\r%s ... %s", msg, string(frames[pos%length]))
fmt.Printf("\r%s ... %s", c(msg), string(frames[pos%length]))
pos += 1
}
}