-
Notifications
You must be signed in to change notification settings - Fork 276
/
main.go
47 lines (39 loc) · 1.13 KB
/
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
43
44
45
46
47
// Copyright The Athenz Authors
// https://github.com/ardielle modified to generate go client code for Athenz Clients
// Licensed under the terms of the Apache version 2.0 license. See LICENSE file for terms.
package main
import (
"flag"
"fmt"
"os"
"github.com/ardielle/ardielle-go/rdl"
)
const RdlGoImport = "github.com/ardielle/ardielle-go/rdl"
func main() {
banner := "rdl (development version)"
if rdl.Version != "" {
banner = fmt.Sprintf("rdl %s", rdl.Version)
}
pOutdir := flag.String("o", ".", "Output directory")
pSchemaFile := flag.String("s", "", "RDL source file")
flag.Parse()
schema, err := rdl.ParseRDLFile(*pSchemaFile, false, false, false)
if err == nil {
generateGoModel(banner, schema, *pOutdir)
os.Exit(0)
}
fmt.Fprintf(os.Stderr, "*** %v\n", err)
os.Exit(1)
}
func generateGoModel(banner string, schema *rdl.Schema, outdir string) error {
return GenerateAthenzGoModel(schema, &GeneratorParams{
Outdir: outdir,
Banner: banner,
Namespace: "",
LibRdl: RdlGoImport,
PrefixEnums: false,
PreciseTypes: true,
UntaggedUnions: []string{},
GenerateSchema: true,
})
}