blob: ca70f3ce272d1afcaa91e22c5ce7bca0defe6825 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package app
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
)
type teaProgram interface {
Run() (tea.Model, error)
}
var programFactory = func(m tea.Model) teaProgram {
return tea.NewProgram(m, tea.WithAltScreen())
}
// Run bootstraps the Bubble Tea program with the provided options.
func Run(opts Options) error {
model, err := newModel(opts)
if err != nil {
return fmt.Errorf("create model: %w", err)
}
program := programFactory(model)
if _, err := program.Run(); err != nil {
return fmt.Errorf("run program: %w", err)
}
return nil
}
|