Files
2025-09-25 02:49:27 +08:00

50 lines
1.5 KiB
Go

package config
type ErlangGeneratorCfg struct {
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
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:"value" json:"value"`
}
func DefaultErlConfig() *ErlangGeneratorCfg {
return &ErlangGeneratorCfg{
TemplateDirPattern: "./templates/*.tpl",
Keywords: []ErlangTemKey{
{
Name: "GamePort",
MainTemplate: "PublicPort",
Filename: "*_port.erl",
OutputSep: "plugin\\game",
OutDirName: ".cfg",
InFileExt: ".erl",
OutFileExt: "_gen.cfg",
DefaultArgs: []DefaultArg{
{
Key: "template",
Value: "_Z_SESSION",
},
{
Key: "project",
Value: "Project",
},
},
},
},
}
}