forked from xinliangnote/go-gin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 718 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
package main
import (
"flag"
"log"
"os"
"strings"
"github.com/xinliangnote/go-gin-api/cmd/gormgen/pkg"
)
var (
input string
structs []string
)
func init() {
flagStructs := flag.String("structs", "", "[Required] The name of schema structs to generate structs for, comma seperated\n")
flagInput := flag.String("input", "", "[Required] The name of the input file dir\n")
flag.Parse()
if *flagStructs == "" || *flagInput == "" {
flag.Usage()
os.Exit(1)
}
structs = strings.Split(*flagStructs, ",")
input = *flagInput
}
func main() {
gen := pkg.NewGenerator(input)
p := pkg.NewParser(input)
if err := gen.ParserAST(p, structs).Generate().Format().Flush(); err != nil {
log.Fatalln(err)
}
}