优化缓存机制 补充错误码
This commit is contained in:
+13
-9
@@ -9,7 +9,6 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Pb2Port struct {
|
||||
@@ -113,20 +112,25 @@ func init() {
|
||||
|
||||
// 写入默认数据
|
||||
if currentDir, err := os.Getwd(); err == nil {
|
||||
out = fmt.Sprintf("%s_port.erl", filepath.Base(currentDir))
|
||||
pluginSpilt := strings.Split(currentDir, "plugin")
|
||||
if len(pluginSpilt) > 0 {
|
||||
pluginSpilt = pluginSpilt[:len(pluginSpilt)-1]
|
||||
protoPath = filepath.Join(strings.Join(pluginSpilt, "plugin"), fmt.Sprintf("\\gpb\\game\\pro_%s.proto", filepath.Base(currentDir)))
|
||||
outPut, _ := globalCache.GetDefault(fmt.Sprintf("%s.out", logsCmd.Use), "%s_port.erl")
|
||||
out = fmt.Sprintf(outPut.(string), filepath.Base(currentDir))
|
||||
|
||||
plugin, _ := globalCache.GetDefault(fmt.Sprintf("%s.Plugin", logsCmd.Use), "plugin")
|
||||
pluginPathByWd, err := zm_lib.GetPluginPathByWd(plugin.(string))
|
||||
if err == nil {
|
||||
defaultProtoPath, _ := globalCache.GetDefault(fmt.Sprintf("%s.Proto", logsCmd.Use), "\\gpb\\game\\pro_%s.proto")
|
||||
protoPath = filepath.Join(pluginPathByWd, fmt.Sprintf(defaultProtoPath.(string), filepath.Base(currentDir)))
|
||||
}
|
||||
}
|
||||
|
||||
logsCmd.PersistentFlags().BoolVar(&singleSet.debug, "debug", false, "是否启动调试模式")
|
||||
logsCmd.PersistentFlags().StringVar(&singleSet.protoPath, "proto", protoPath, "读取文件")
|
||||
logsCmd.PersistentFlags().StringVar(&singleSet.out, "out", out, "输出文件")
|
||||
logsCmd.PersistentFlags().StringVar(&singleSet.author, "author", "st,sutong@youkia.net", "作者")
|
||||
logsCmd.PersistentFlags().StringVar(&singleSet.mainTemplate, "main_tpl", "ErlangPort", "主模版")
|
||||
logsCmd.PersistentFlags().StringVar(&singleSet.tplDir, "tpl", "./templates/*.tpl", "模版地址")
|
||||
_ = zm_lib.PersistentFlagsStringVar(logsCmd, &singleSet.author, globalCache, "author", "st,sutong@youkia.net", "作者")
|
||||
_ = zm_lib.PersistentFlagsStringVar(logsCmd, &singleSet.mainTemplate, globalCache, "main_tpl", "ErlangPort", "主模版")
|
||||
_ = zm_lib.PersistentFlagsStringVar(logsCmd, &singleSet.tplDir, globalCache, "tpl", "./templates/*.tpl", "模版地址")
|
||||
//logsCmd.PersistentFlags().StringVar(&singleSet.mainTemplate, "main_tpl", "ErlangPort", "主模版")
|
||||
//logsCmd.PersistentFlags().StringVar(&singleSet.tplDir, "tpl", "./templates/*.tpl", "模版地址")
|
||||
|
||||
rootCmd.AddCommand(logsCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user