mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
38 lines
718 B
Go
38 lines
718 B
Go
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)
|
|
}
|
|
}
|