forked from davyxu/tabtoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry_v2.go
89 lines (69 loc) · 1.91 KB
/
entry_v2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"flag"
"github.com/davyxu/tabtoy/build"
"github.com/davyxu/tabtoy/v2"
"github.com/davyxu/tabtoy/v2/i18n"
"github.com/davyxu/tabtoy/v2/printer"
"os"
)
// v2特有
var (
paramProtoVersion = flag.Int("protover", 3, "output .proto file version, 2 or 3")
paramLuaEnumIntValue = flag.Bool("luaenumintvalue", false, "use int type in lua enum value")
paramLuaTabHeader = flag.String("luatabheader", "", "output string to lua tab header")
paramGenCSharpBinarySerializeCode = flag.Bool("cs_gensercode", true, "generate c# binary serialize code, default is true")
)
func V2Entry() {
g := printer.NewGlobals()
if !i18n.SetLanguage(*paramLanguage) {
log.Infof("language not support: %s", *paramLanguage)
os.Exit(1)
}
g.Version = build.Version
for _, v := range flag.Args() {
g.InputFileList = append(g.InputFileList, v)
}
g.ParaMode = *paramPara
g.CacheDir = *paramCacheDir
g.UseCache = *paramUseCache
g.CombineStructName = *paramCombineStructName
g.ProtoVersion = *paramProtoVersion
g.LuaEnumIntValue = *paramLuaEnumIntValue
g.LuaTabHeader = *paramLuaTabHeader
g.GenCSSerailizeCode = *paramGenCSharpBinarySerializeCode
g.PackageName = *paramPackageName
if *paramProtoOut != "" {
g.AddOutputType("proto", *paramProtoOut)
}
if *paramPbtOut != "" {
g.AddOutputType("pbt", *paramPbtOut)
}
if *paramJsonOut != "" {
g.AddOutputType("json", *paramJsonOut)
}
if *paramLuaOut != "" {
g.AddOutputType("lua", *paramLuaOut)
}
if *paramCSharpOut != "" {
g.AddOutputType("cs", *paramCSharpOut)
}
if *paramGoOut != "" {
g.AddOutputType("go", *paramGoOut)
}
if *paramCppOut != "" {
g.AddOutputType("cpp", *paramCppOut)
}
if *paramBinaryOut != "" {
g.AddOutputType("bin", *paramBinaryOut)
}
if *paramTypeOut != "" {
g.AddOutputType("type", *paramTypeOut)
}
if *paramModifyList != "" {
g.AddOutputType("modlist", *paramModifyList)
}
if !v2.Run(g) {
os.Exit(1)
}
}