51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
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"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var playerCmd = &cobra.Command{
|
|
Use: "player",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
logger, _ := zap.Config{
|
|
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
|
|
Encoding: "json",
|
|
OutputPaths: []string{"logs/player-stdout.log"},
|
|
ErrorOutputPaths: []string{"logs/player-stderr.log"},
|
|
EncoderConfig: zap.NewProductionEncoderConfig(),
|
|
}.Build()
|
|
undo := zap.ReplaceGlobals(logger)
|
|
defer undo()
|
|
|
|
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,
|
|
})
|
|
|
|
for base.Size() > 0 {
|
|
p := base.Pop()
|
|
if err := p.Run(); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
playerCmd.Flags().
|
|
String("host", "127.0.0.1", "")
|
|
playerCmd.Flags().
|
|
Int("udp-listen-port", 18787, "")
|
|
playerCmd.Flags().
|
|
StringSlice("udp-endpoints", []string{"localhost:18787"}, "")
|
|
playerCmd.Flags().
|
|
String("auth-endpoint", "http://localhost:8888", "")
|
|
}
|