feat: first version.

This commit is contained in:
tx7do
2023-05-21 10:04:15 +08:00
parent 3656de9753
commit 785443dd84
51 changed files with 15841 additions and 0 deletions

35
flag.go Normal file
View File

@@ -0,0 +1,35 @@
package bootstrap
import "flag"
type CommandFlags struct {
Conf string // 引导配置文件路径,默认为:../../configs
Env string // 开发环境dev、debug……
ConfigHost string // 远程配置服务端地址
ConfigType string // 远程配置服务端类型
Daemon bool // 是否转为守护进程
}
func NewCommandFlags() *CommandFlags {
return &CommandFlags{
Conf: "",
Env: "",
ConfigHost: "",
ConfigType: "",
Daemon: false,
}
}
func (f *CommandFlags) Init() {
flag.StringVar(&f.Conf, "conf", "../../configs", "config path, eg: -conf ../../configs")
flag.StringVar(&f.Env, "env", "dev", "runtime environment, eg: -env dev")
flag.StringVar(&f.ConfigHost, "chost", "127.0.0.1:8500", "config server host, eg: -chost 127.0.0.1:8500")
flag.StringVar(&f.ConfigType, "ctype", "consul", "config server host, eg: -ctype consul")
flag.BoolVar(&f.Daemon, "d", false, "run app as a daemon with -d=true.")
if f.Daemon {
BeDaemon("-d")
}
flag.Parse()
}