-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
42 lines (34 loc) · 1001 Bytes
/
main.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
package main
import (
"flag"
"log"
"github.com/joefitzgerald/openair/generator"
"github.com/kelseyhightower/envconfig"
)
var (
objectNames = flag.String("object", "", "comma-separated list of OpenAir XML Datatype names; must be set")
outputPrefix = flag.String("prefix", "", "prefix to be added to the output file")
outputSuffix = flag.String("suffix", "_openair", "suffix to be added to the output file")
)
func main() {
flag.Parse()
if len(*objectNames) == 0 {
log.Fatalf("the flag -object must be set")
}
// Only one directory at a time can be processed, and the default is ".".
dir := "."
if args := flag.Args(); len(args) == 1 {
dir = args[0]
} else if len(args) > 1 {
log.Fatalf("only one directory at a time")
}
var c generator.Config
err := envconfig.Process("openair", &c)
if err != nil {
log.Fatal(err)
}
g := generator.New(c, *objectNames, dir, *outputPrefix, *outputSuffix)
g.GenerateCommonFile()
g.GenerateCommonTestFile()
g.GenerateModelFiles()
}