Draft: big refactor

This commit is contained in:
2025-09-16 16:03:27 +08:00
parent f527230f1e
commit c4f2b0af25
42 changed files with 684 additions and 215 deletions

View File

@@ -6,6 +6,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/go-resty/resty/v2"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
var RootCmd = &cobra.Command{
@@ -15,25 +16,35 @@ var RootCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
appname := "game-tui"
tracing.InitTracer(appname)
defer tracing.DeferTracer()
tracing.Logger.
Info("client up")
client := resty.New().
SetBaseURL(args[0]).
SetDisableWarn(true)
queue := []*tea.Program{}
queue = append(queue,
tea.NewProgram(plays.NewLanding(plays.NewBase(client))))
queue = append(queue, tea.NewProgram(
plays.NewLanding(plays.NewBase(client))))
for len(queue) > 0 {
program := queue[0]
queue = queue[1:]
tracing.Logger.Info("run program")
res, err := program.Run()
if err != nil {
tracing.Logger.Error("program failed",
zap.Error(err))
panic(err)
}
err = res.(plays.Next).Next(&queue)
if err != nil {
tracing.Logger.Error("failed to generate next program",
zap.Error(err))
panic(err)
}
}
@@ -41,4 +52,7 @@ var RootCmd = &cobra.Command{
}
func init() {
RootCmd.Flags().
String("otel-endpoint", "localhost:4317",
"endpoint for otlp exporter to connect")
}