Files
inp2025/cmd/play/root.go
2025-09-09 15:36:23 +08:00

37 lines
702 B
Go

package play
import (
"gitea.konchin.com/ytshih/inp2025/game/plays"
tea "github.com/charmbracelet/bubbletea"
"github.com/go-resty/resty/v2"
"github.com/spf13/cobra"
)
var RootCmd = &cobra.Command{
Use: "play",
Short: "Play game",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
client := resty.New().
SetBaseURL(args[0])
queue := []*tea.Program{}
queue = append(queue,
tea.NewProgram(plays.NewLanding(plays.NewBase(client))))
for len(queue) > 0 {
program := queue[0]
queue = queue[1:]
res, err := program.Run()
if err != nil {
panic(err)
}
err = res.(plays.Next).Next(&queue)
if err != nil {
panic(err)
}
}
},
}