From 49c2d264b5285b9a9359fc53480890b3a595218e Mon Sep 17 00:00:00 2001 From: Kaxi <1042864399@qq.com> Date: Sat, 27 Sep 2025 01:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF=E7=A0=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/errcode.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cmd/errcode.go diff --git a/cmd/errcode.go b/cmd/errcode.go new file mode 100644 index 0000000..6991323 --- /dev/null +++ b/cmd/errcode.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "os" + "path/filepath" + "strings" +) + +type ErrCode struct { + debug bool + + ErrPath string +} + +func (s *ErrCode) run(_ *cobra.Command, arg []string) { + +} + +func init() { + var singleSet = new(ErrCode) + var logsCmd = &cobra.Command{ + Use: "err_code", + Short: "根据proto 文件构建 功能模版", + Long: `构建功能数据`, + Run: singleSet.run, + } + + var errorLanguagePath = "" + + // 写入默认数据 + if currentDir, err := os.Getwd(); err == nil { + pluginSpilt := strings.Split(currentDir, "plugin") + if len(pluginSpilt) > 0 { + pluginSpilt = pluginSpilt[:len(pluginSpilt)-1] + errorLanguagePath = filepath.Join(strings.Join(pluginSpilt, "plugin"), ".cfg/ErrorLanguage.txt") + } + } + + logsCmd.PersistentFlags().BoolVar(&singleSet.debug, "debug", false, "是否启动调试模式") + logsCmd.PersistentFlags().StringVar(&singleSet.ErrPath, "path", errorLanguagePath, "错误码地址") + + rootCmd.AddCommand(logsCmd) +}