dynamo-browse/internal/common/ui/events/commands.go
Leon Mika 41af399215 A few various changes
- Fixed the '-local' flag to accept host and port
- Added a '-debug' flag to accept a file to write debug log messages
- Added some logic which will force the dark background flag on if MacOS is in dark mode
2022-06-16 22:00:25 +10:00

46 lines
754 B
Go

package events
import (
tea "github.com/charmbracelet/bubbletea"
"log"
)
func Error(err error) tea.Msg {
log.Println(err)
return ErrorMsg(err)
}
func SetError(err error) tea.Cmd {
return func() tea.Msg {
return Error(err)
}
}
func SetStatus(msg string) tea.Cmd {
return func() tea.Msg {
return StatusMsg(msg)
}
}
func PromptForInput(prompt string, onDone func(value string) tea.Cmd) tea.Cmd {
return func() tea.Msg {
return PromptForInputMsg{
Prompt: prompt,
OnDone: onDone,
}
}
}
func Confirm(prompt string, onYes func() tea.Cmd) tea.Cmd {
return PromptForInput(prompt, func(value string) tea.Cmd {
if value == "y" {
return onYes()
}
return nil
})
}
type MessageWithStatus interface {
StatusMessage() string
}