forked from goadesign/goa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.go
38 lines (33 loc) · 1 KB
/
run.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
package codegen
import "github.com/goadesign/goa/dslengine"
type generator interface {
Generate() ([]string, error)
}
// Run runs all generators passed as parameter. Call ParseDSL first to
// fill `design.Design`. Each `goa` generator lives in its own
// `goagen/gen_something` package in `generator.go` and has a
// `Generator` object which implements the interface required here.
//
// codegen.Run(
// &genapp.Generator{
// API: design.Design,
// Target: "app",
// },
// &genmain.Generator{
// API: design.Design,
// },
// )
//
func Run(generators ...generator) {
for _, generator := range generators {
dslengine.PrintFilesOrFail(generator.Generate())
}
}
// ParseDSL will run the DSL engine and analyze any imported `design`
// package, creating your `design.APIDefinition` along the way.
func ParseDSL() {
// Catch any init-time errors
dslengine.FailOnError(dslengine.Errors)
// Catch any runtime errors, when analyzing the DSL
dslengine.FailOnError(dslengine.Run())
}