dynamo-browse/internal/common/ui/events/commands.go
Leon Mika 79692302af
Issue 23: Added progress indicators and cancellation (#34)
- Wrapped all table operations in a new foreground job context, which mediates foreground tasks.
- Added cancellation support and partial results for table read operations.
- Added the "mark" command, which can mark, unmark & toggle marked items
- Added support for alias arguments.
- Removed the "unmark" command, and replaced it as an alias to the "marked" command
- Fixed seg faults raised when there is no table shown in the result set.
2022-10-10 10:15:25 +11:00

55 lines
976 B
Go

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