Draft: feat login
This commit is contained in:
36
cmd/play/root.go
Normal file
36
cmd/play/root.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package play
|
||||
|
||||
import (
|
||||
"gitea.konchin.com/ytshih/inp2025/game/plays"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "play",
|
||||
Short: "Play game",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
landing:
|
||||
landing, err := tea.NewProgram(plays.NewLanding()).Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
switch landing.(*plays.Landing).Choice {
|
||||
case "Register":
|
||||
case "Login":
|
||||
login, err := tea.NewProgram(plays.NewLogin()).Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if login.(*plays.Login).User == nil {
|
||||
_, err := tea.NewProgram(
|
||||
plays.NewRedirect("User did not login")).Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
goto landing
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user