mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-13 00:42:30 +08:00
refactor
This commit is contained in:
23
cmd/hk4e/dispatch.go
Normal file
23
cmd/hk4e/dispatch.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hk4e/dispatch/app"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// DispatchCmd
|
||||
func DispatchCmd() *cobra.Command {
|
||||
var cfg string
|
||||
c := &cobra.Command{
|
||||
Use: "dispatch",
|
||||
Short: "dispatch server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return app.Run(context.Background(), cfg)
|
||||
},
|
||||
}
|
||||
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
|
||||
return c
|
||||
}
|
||||
23
cmd/hk4e/gate.go
Normal file
23
cmd/hk4e/gate.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hk4e/gate/app"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GateCmd 检查配表命令
|
||||
func GateCmd() *cobra.Command {
|
||||
var cfg string
|
||||
c := &cobra.Command{
|
||||
Use: "gate",
|
||||
Short: "gate server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return app.Run(context.Background(), cfg)
|
||||
},
|
||||
}
|
||||
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
|
||||
return c
|
||||
}
|
||||
23
cmd/hk4e/gm.go
Normal file
23
cmd/hk4e/gm.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hk4e/gm/app"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GMCmd
|
||||
func GMCmd() *cobra.Command {
|
||||
var cfg string
|
||||
c := &cobra.Command{
|
||||
Use: "gm",
|
||||
Short: "gm server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return app.Run(context.Background(), cfg)
|
||||
},
|
||||
}
|
||||
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
|
||||
return c
|
||||
}
|
||||
23
cmd/hk4e/gs.go
Normal file
23
cmd/hk4e/gs.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hk4e/gs/app"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GSCmd
|
||||
func GSCmd() *cobra.Command {
|
||||
var cfg string
|
||||
c := &cobra.Command{
|
||||
Use: "gs",
|
||||
Short: "game server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return app.Run(context.Background(), cfg)
|
||||
},
|
||||
}
|
||||
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
|
||||
return c
|
||||
}
|
||||
33
cmd/hk4e/main.go
Normal file
33
cmd/hk4e/main.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
config = flag.String("config", "application.toml", "config file")
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "hk4e",
|
||||
Short: "hk4e server",
|
||||
SilenceUsage: true,
|
||||
}
|
||||
rootCmd.AddCommand(
|
||||
GSCmd(),
|
||||
GMCmd(),
|
||||
DispatchCmd(),
|
||||
GateCmd(),
|
||||
)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user