Feat: login done
This commit is contained in:
44
cmd/play/root.go
Normal file
44
cmd/play/root.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package play
|
||||
|
||||
import (
|
||||
"gitea.konchin.com/ytshih/inp2025/game/plays"
|
||||
"gitea.konchin.com/ytshih/inp2025/game/tracing"
|
||||
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) {
|
||||
appname := "game-tui"
|
||||
tracing.InitTracer(appname)
|
||||
|
||||
client := resty.New().
|
||||
SetBaseURL(args[0]).
|
||||
SetDisableWarn(true)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
}
|
||||
Reference in New Issue
Block a user