补充完成逻辑

This commit is contained in:
2025-09-25 02:49:27 +08:00
parent ca040bc2b9
commit 7cbb4b2cf9
17 changed files with 394 additions and 822 deletions
+17 -11
View File
@@ -1,32 +1,38 @@
package config
type ErlangGeneratorCfg struct {
TemplateDir string `yaml:"template_dir" json:"template_dir"` // 模板文件存放地址
Keywords []ErlangTemKey `yaml:"keywords" json:"keywords"`
TemplateDirPattern string `yaml:"template_dir_pattern" json:"template_dir_pattern"`
Keywords []ErlangTemKey `yaml:"keywords" json:"keywords"`
}
type ErlangTemKey struct {
Name string `yaml:"name" json:"name"` // 关键key
MainTemplate string `yaml:"main_template" json:"main_template"` // 主模板
Filename string `yaml:"filename" json:"filename"` // _port.erl
OutputDir string `yaml:"output_dir" json:"output_dir"` // 输出地址
OutFileExt string `yaml:"out_file_ext" json:"out_file_ext"` // .cfg
DefaultArgs []DefaultArg `yaml:"default_args" json:"default_args"` // 默认模板参数
Filename string `yaml:"filename" json:"filename"` // *_port.erl
OutputSep string `yaml:"output_sep" json:"output_sep"` // 输出地址
OutDirName string `yaml:"out_dir_name" json:"out_dir_name"`
InFileExt string `yaml:"in_file_ext" json:"in_file_ext"`
OutFileExt string `yaml:"out_file_ext" json:"out_file_ext"` // .cfg
DefaultArgs []DefaultArg `yaml:"default_args" json:"default_args"` // 默认模板参数
}
type DefaultArg struct {
Key string `yaml:"key" json:"key"`
Value string `yaml:"val" json:"Value"`
Value string `yaml:"value" json:"value"`
}
func DefaultErlConfig() *ErlangGeneratorCfg {
return &ErlangGeneratorCfg{
TemplateDir: "./templates",
TemplateDirPattern: "./templates/*.tpl",
Keywords: []ErlangTemKey{
{
MainTemplate: "port.tpl",
Name: "GamePort",
MainTemplate: "PublicPort",
Filename: "*_port.erl",
OutputDir: "output",
OutFileExt: ".cfg",
OutputSep: "plugin\\game",
OutDirName: ".cfg",
InFileExt: ".erl",
OutFileExt: "_gen.cfg",
DefaultArgs: []DefaultArg{
{
Key: "template",
-42
View File
@@ -1,42 +0,0 @@
// config/generator_config.go
package config
type GeneratorConfig struct {
// 扫描配置
ScanDir string `yaml:"scan_dir" json:"scan_dir"`
FilePatterns []string `yaml:"file_patterns" json:"file_patterns"`
OutputFile string `yaml:"output_file" json:"output_file"`
// 注解关键词配置
Keywords []KeywordConfig `yaml:"keywords" json:"keywords"`
// 模板配置
TemplateFile string `yaml:"template_file" json:"template_file"`
// 忽略的目录
IgnoreDirs []string `yaml:"ignore_dirs" json:"ignore_dirs"`
}
type KeywordConfig struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Required bool `yaml:"required" json:"required"`
}
// 默认配置
func DefaultConfig() *GeneratorConfig {
return &GeneratorConfig{
ScanDir: "./",
FilePatterns: []string{"*.erl", "*.hrl"},
OutputFile: "./generated/app.config",
TemplateFile: "./templates/config_template.tplerl",
IgnoreDirs: []string{".git", "node_modules", "_build", "deps"},
Keywords: []KeywordConfig{
{Name: "config", Description: "配置项定义", Required: true},
{Name: "module", Description: "模块配置", Required: false},
{Name: "function", Description: "函数配置", Required: false},
{Name: "param", Description: "参数配置", Required: false},
{Name: "type", Description: "类型配置", Required: false},
},
}
}