chore: refactoring status updates

This commit is contained in:
adamdottv 2025-05-08 12:03:59 -05:00
commit f41b7bbd0a
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
24 changed files with 366 additions and 264 deletions

View file

@ -1,8 +1,6 @@
package util
import (
"time"
tea "github.com/charmbracelet/bubbletea"
)
@ -12,44 +10,6 @@ func CmdHandler(msg tea.Msg) tea.Cmd {
}
}
func ReportError(err error) tea.Cmd {
return CmdHandler(InfoMsg{
Type: InfoTypeError,
Msg: err.Error(),
})
}
type InfoType int
const (
InfoTypeInfo InfoType = iota
InfoTypeWarn
InfoTypeError
)
func ReportInfo(info string) tea.Cmd {
return CmdHandler(InfoMsg{
Type: InfoTypeInfo,
Msg: info,
})
}
func ReportWarn(warn string) tea.Cmd {
return CmdHandler(InfoMsg{
Type: InfoTypeWarn,
Msg: warn,
})
}
type (
InfoMsg struct {
Type InfoType
Msg string
TTL time.Duration
}
ClearStatusMsg struct{}
)
func Clamp(v, low, high int) int {
if high < low {
low, high = high, low