dynamo-browse/internal/dynamo-browse/controllers/commands.go
2022-08-18 21:39:13 +10:00

26 lines
600 B
Go

package controllers
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/lmika/audax/internal/common/ui/events"
)
type promptSequence struct {
prompts []string
receivedValues []string
onAllDone func(values []string) tea.Msg
}
func (ps *promptSequence) next() tea.Msg {
if len(ps.receivedValues) < len(ps.prompts) {
return events.PromptForInputMsg{
Prompt: ps.prompts[len(ps.receivedValues)],
OnDone: func(value string) tea.Msg {
ps.receivedValues = append(ps.receivedValues, value)
return ps.next()
},
}
}
return ps.onAllDone(ps.receivedValues)
}