summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/util
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-07 19:43:31 +0200
committerKujtim Hoxha <[email protected]>2025-04-07 19:43:31 +0200
commitf463ce6694143a8f17953ca029d4c274d0193edd (patch)
tree6cb6c416fb07065303862ac461fcbad3311badb7 /internal/tui/util
parent57a2210d8d81efe43a41aa09538f4e26b6f6f374 (diff)
downloadopencode-f463ce6694143a8f17953ca029d4c274d0193edd.tar.gz
opencode-f463ce6694143a8f17953ca029d4c274d0193edd.zip
improve status message handling
Diffstat (limited to 'internal/tui/util')
-rw-r--r--internal/tui/util/util.go33
1 files changed, 30 insertions, 3 deletions
diff --git a/internal/tui/util/util.go b/internal/tui/util/util.go
index f6cf20d60..e006cbb43 100644
--- a/internal/tui/util/util.go
+++ b/internal/tui/util/util.go
@@ -9,12 +9,39 @@ func CmdHandler(msg tea.Msg) tea.Cmd {
}
func ReportError(err error) tea.Cmd {
- return CmdHandler(ErrorMsg(err))
+ 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 string
- ErrorMsg error
+ InfoMsg struct {
+ Type InfoType
+ Msg string
+ }
ClearStatusMsg struct{}
)