chore: refactoring status updates

This commit is contained in:
adamdottv
2025-05-08 12:03:59 -05:00
parent e35ea2d448
commit f41b7bbd0a
24 changed files with 367 additions and 265 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