mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 03:04:21 +01:00
chore: refactoring status updates
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user