1 Star 0 Fork 0

gongpeng / keyauth-gp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
root.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
gongpeng 提交于 2023-03-12 21:56 . 生成用户中心的模版
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"gitee.com/gongpengABC/keyauth-gp/version"
)
var (
// pusher service config option
confType string
confFile string
confETCD string
)
var vers bool
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "keyauth-gp",
Short: "用户中心",
Long: "用户中心",
RunE: func(cmd *cobra.Command, args []string) error {
if vers {
fmt.Println(version.FullVersion())
return nil
}
return cmd.Help()
},
}
// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
}
func init() {
RootCmd.PersistentFlags().StringVarP(&confType, "config-type", "t", "file", "the service config type [file/env/etcd]")
RootCmd.PersistentFlags().StringVarP(&confFile, "config-file", "f", "etc/config.toml", "the service config from file")
RootCmd.PersistentFlags().StringVarP(&confETCD, "config-etcd", "e", "127.0.0.1:2379", "the service config from etcd")
RootCmd.PersistentFlags().BoolVarP(&vers, "version", "v", false, "the keyauth-gp version")
}
Go
1
https://gitee.com/gongpengABC/keyauth-gp.git
git@gitee.com:gongpengABC/keyauth-gp.git
gongpengABC
keyauth-gp
keyauth-gp
v0.0.9

搜索帮助