整理打印

This commit is contained in:
2025-10-03 00:54:22 +08:00
parent bff7f73d8b
commit 73480005eb
6 changed files with 63 additions and 3 deletions
+5 -1
View File
@@ -78,6 +78,8 @@ func (s *Pb2Port) run(_ *cobra.Command, arg []string) {
return
}
if err == nil {
abs1, _ := filepath.Abs(s.out)
fmt.Printf("[warn] 原文件已存在 > %s:1\n", abs1)
s.out = filepath.Base(s.out)[:len(filepath.Base(s.out))-len(filepath.Ext(s.out))]
s.out = s.out + "_gen.erl"
}
@@ -91,7 +93,9 @@ func (s *Pb2Port) run(_ *cobra.Command, arg []string) {
log.Printf("Err 写入文件失败: %v", err)
return
}
fmt.Println("ok")
abs, _ := filepath.Abs(s.out)
fmt.Printf(" \n生成文件\n > %s:0\n", abs)
}
func init() {
var singleSet = new(Pb2Port)
+19 -2
View File
@@ -4,6 +4,8 @@ import (
"complie-erlang/config"
tm "complie-erlang/template"
"complie-erlang/worker"
"fmt"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
"log"
"os"
@@ -62,7 +64,7 @@ func ExecuteSingleDir(args []string) {
}
for _, filename := range erlFiles {
log.Printf("[info] 检索到文件: %v %s\n", cfgPublic.Filename, filename)
fmt.Printf("[info] 检索到文件: %v %s:1\n", cfgPublic.Filename, filename)
// 根据配置解析出 文件数据
parseTemKey, err := worker1.ParseTemKey(filename, cfgPublic)
if err != nil {
@@ -89,8 +91,23 @@ func ExecuteSingleDir(args []string) {
log.Printf("[warn] 生成文件失败: %v %s", err, outFileNema)
continue
}
log.Printf("[info] 生成文件: %s\n", outFileNema)
fmt.Printf("[info] 生成文件: %s:1\n\n", outFileNema)
}
}
}
func init() {
var logsCmd = &cobra.Command{
Use: "cfg",
Short: "配置生成",
Long: `根据 标注 构建 功能配置模版`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
args = []string{"config.yaml"}
}
ExecuteSingleDir(args)
},
}
rootCmd.AddCommand(logsCmd)
}