forked from grid/firemodel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiremodel.go
46 lines (39 loc) · 827 Bytes
/
firemodel.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
package firemodel
import (
"io"
"github.com/go-errors/errors"
)
type SourceCoder interface {
NewFile(filename string) (io.WriteCloser, error)
Flush() error
}
type Modeler interface {
Model(schema *Schema, sourceCoder SourceCoder) error
}
type Client interface {
}
func Run(
schema *Schema,
config *Config,
) error {
if config == nil {
err := errors.New("firemodel: config not set")
return err
}
for _, language := range config.Languages {
if err := func(language *Language) error {
modeler := language.Modeler()
sourceCoder := config.SourceCoderProvider(language.Output)
if err := modeler.Model(schema, sourceCoder); err != nil {
return err
}
if err := sourceCoder.Flush(); err != nil {
return err
}
return nil
}(&language); err != nil {
return err
}
}
return nil
}