This commit is contained in:
partisan 2025-03-09 11:42:53 +01:00
commit d0187f94d7
23 changed files with 2489 additions and 0 deletions

31
spm/progress.go Normal file
View file

@ -0,0 +1,31 @@
package spm
import (
"fmt"
"sync"
)
type Progress struct {
mu sync.Mutex
percentage int
task string
}
var progress = Progress{}
// UpdateProgress sets the current percentage and task.
func UpdateProgress(percentage int, task string) {
progress.mu.Lock()
defer progress.mu.Unlock()
progress.percentage = percentage
progress.task = task
fmt.Printf("\r[%3d%%] %s", percentage, task) // Print progress to the terminal
// Next line on 100% ?
}
// GetProgress returns the current progress state.
func GetProgress() (int, string) {
progress.mu.Lock()
defer progress.mu.Unlock()
return progress.percentage, progress.task
}