gameapi

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CMD = func() *cli.Command {

	var name string    // 名称
	var option string  // 操作符
	var addr string    // 监听地址
	var instanceID int // 实例ID
	var network string // 使用协议
	var natsUrl string // nats地址
	var etcdUrl string // etcd地址,多实例用 `,`分割

	return &cli.Command{
		Name:  "game",
		Usage: "create a game api",
		Action: func(ctx *cli.Context) error {
			if name == "" {
				return errors.New("must a name")
			}

			switch option {
			case "c":
				create(name, addr, instanceID, network, natsUrl, etcdUrl)
			case "g":
				generate(name)
			default:
				return errors.New("wrong option")
			}

			return nil
		},
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:        "name, n",
				Usage:       "game server name",
				Destination: &name,
			},
			&cli.StringFlag{
				Name:        "option, o",
				Usage:       "option code, eg. c create; g gerante proto;",
				Destination: &option,
				Value:       "c",
			},
			&cli.StringFlag{
				Name:        "addr, a",
				Usage:       "game server listen address",
				Destination: &addr,
				Value:       "127.0.0.1:8080",
			},
			&cli.IntFlag{
				Name:        "id, i",
				Usage:       "game server intance id",
				Destination: &instanceID,
				Value:       1,
			},
			&cli.StringFlag{
				Name:        "network",
				Usage:       "game server use network",
				Destination: &network,
				Value:       "kcp",
			},
			&cli.StringFlag{
				Name:        "nats",
				Usage:       "nats address",
				Destination: &natsUrl,
				Value:       "nats://127.0.0.1:4222",
			},
			&cli.StringFlag{
				Name:        "etcd",
				Usage:       "etcd address, use , splite",
				Destination: &etcdUrl,
				Value:       "127.0.0.1:2379",
			},
		},
	}
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL