添加错误码自动提取
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user