Fix: various bug fix
This commit is contained in:
20
player.go
20
player.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"gitea.konchin.com/ytshih/inp2025/stages"
|
||||
"gitea.konchin.com/ytshih/inp2025/types"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -10,17 +11,16 @@ import (
|
||||
var playerCmd = &cobra.Command{
|
||||
Use: "player",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
queue := []*tea.Program{}
|
||||
base := stages.NewBaseModel(viper.GetString("auth-endpoint"))
|
||||
p := tea.NewProgram(stages.NewLandingModel(base))
|
||||
base.Push(types.Program{
|
||||
Run: func() error { _, err := p.Run(); return err },
|
||||
Stage: types.StageLanding,
|
||||
})
|
||||
|
||||
base := stages.NewBaseModel(&queue, viper.GetString("auth-endpoint"))
|
||||
queue = append(queue,
|
||||
tea.NewProgram(stages.NewLandingModel(base)))
|
||||
|
||||
for len(queue) > 0 {
|
||||
program := queue[0]
|
||||
queue = queue[1:]
|
||||
_, err := program.Run()
|
||||
if err != nil {
|
||||
for base.Size() > 0 {
|
||||
p := base.Pop()
|
||||
if err := p.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user