-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
133 lines (126 loc) · 3.88 KB
/
structs.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package main
import (
"encoding/json"
"io"
)
type AutoColorRule struct {
Selection string `json:"selection"`
Color string `json:"color"`
Translucency int `json:"translucency,omitempty"`
}
type DumpAttOption struct {
Filename string `json:"filename"`
Selection string `json:"selection"`
AdditionalAtts []string `json:"additionalAtts"`
HasNoData bool `json:"hasNoData"`
HasUda bool `json:"hasUda"`
}
type ExportOption struct {
Filename string `json:"filename,omitempty"`
RvmType string `json:"rvmType,omitempty"`
Filenote string `json:"filenote,omitempty"`
Encoding string `json:"encoding,omitempty"`
ImpliedTube string `json:"impliedTube,omitempty"`
Holes string `json:"holes,omitempty"`
Repr string `json:"repr,omitempty"`
ReprCl string `json:"reprCl,omitempty"`
ReprTube string `json:"reprTube,omitempty"`
ReprInsu string `json:"reprInsu,omitempty"`
ReprObst string `json:"reprObst,omitempty"`
ReprLevel int `json:"reprLevel,omitempty"`
ReprLevelPipe int `json:"reprLevelPipe,omitempty"`
ReprLevelNozz int `json:"reprLevelNozz,omitempty"`
ReprLevelStru int `json:"reprLevelStru,omitempty"`
AutoColor string `json:"autoColor,omitempty"`
AutoColorDisplayExport string `json:"autoColorDisplayExport,omitempty"`
GlobalTranslucency int `json:"globalTranslucency,omitempty"`
AutoColorRules []AutoColorRule `json:"autoColorRules,omitempty"`
ExportInclude []string `json:"exportInclude,omitempty"`
ExportExclude []string `json:"exportExclude,omitempty"`
}
type RvmBuilder struct {
Filename string `json:"filename"`
WorkingDir string `json:"workingDir"`
FiletoolsTaskRunner string `json:"filetoolsTaskRunner"`
NwdVersion string `json:"nwdVersion"`
ExportDefault ExportOption `json:"exportDefault"`
ExportRvms []ExportOption `json:"exportRvms"`
DumpAtt bool `json:"dumpAtt"`
DumpAttOption DumpAttOption `json:"dumpAttOption"`
}
func LoadRvmBuilder(i io.Reader) (*RvmBuilder, error) {
j, err := io.ReadAll(i)
if err != nil {
return nil, err
}
var b RvmBuilder
if err := json.Unmarshal(j, &b); err != nil {
return nil, err
}
return &b, nil
}
func (e *ExportOption) Merge(o *ExportOption) {
if o.Filename != "" {
e.Filename = o.Filename
}
if o.RvmType != "" {
e.RvmType = o.RvmType
}
if o.Filenote != "" {
e.Filenote = o.Filenote
}
if o.Encoding != "" {
e.Encoding = o.Encoding
}
if o.ImpliedTube != "" {
e.ImpliedTube = o.ImpliedTube
}
if o.Holes != "" {
e.Holes = o.Holes
}
if o.Repr != "" {
e.Repr = o.Repr
}
if o.ReprCl != "" {
e.ReprCl = o.ReprCl
}
if o.ReprTube != "" {
e.ReprTube = o.ReprTube
}
if o.ReprInsu != "" {
e.ReprInsu = o.ReprInsu
}
if o.ReprObst != "" {
e.ReprObst = o.ReprObst
}
if o.ReprLevel != 0 {
e.ReprLevel = o.ReprLevel
}
if o.ReprLevelPipe != 0 {
e.ReprLevelPipe = o.ReprLevelPipe
}
if o.ReprLevelNozz != 0 {
e.ReprLevelNozz = o.ReprLevelNozz
}
if o.ReprLevelStru != 0 {
e.ReprLevelStru = o.ReprLevelStru
}
if o.AutoColor != "" {
e.AutoColor = o.AutoColor
}
if o.AutoColorDisplayExport != "" {
e.AutoColorDisplayExport = o.AutoColorDisplayExport
}
if o.GlobalTranslucency != 0 {
e.GlobalTranslucency = o.GlobalTranslucency
}
if len(o.AutoColorRules) != 0 {
e.AutoColorRules = o.AutoColorRules
}
if len(o.ExportInclude) != 0 {
e.ExportInclude = o.ExportInclude
}
if len(o.ExportExclude) != 0 {
e.ExportExclude = o.ExportExclude
}
}