2023-01-09 18:54:21 +00:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"gospt/internal/gctx"
|
|
|
|
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"github.com/zmb3/spotify/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StartTea the entry point for the UI. Initializes the model.
|
2023-01-11 17:45:29 +00:00
|
|
|
func StartTea(ctx *gctx.Context, client *spotify.Client, mode string) error {
|
2023-01-09 18:54:21 +00:00
|
|
|
if f, err := tea.LogToFile("debug.log", "help"); err != nil {
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
defer func() {
|
|
|
|
err = f.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
2023-01-11 17:45:29 +00:00
|
|
|
m, err := InitMain(ctx, client, mode)
|
2023-01-09 18:54:21 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("UH OH")
|
|
|
|
}
|
|
|
|
P = tea.NewProgram(m, tea.WithAltScreen())
|
|
|
|
if err := P.Start(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|