-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_models.go
47 lines (39 loc) · 937 Bytes
/
gen_models.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
/**
* Created GoLand.
* User: liyw<634482545@qq.com>
* Date: 2023-08-04
* File: gen_models.go
* Desc: generate model
*/
package cmd
import (
"github.com/go-mumu/cs-go/service/container"
"github.com/go-mumu/cs-go/service/dal"
"github.com/spf13/cobra"
)
// Usage: go run main.go gen-model -d defMysql
// var Args string
//
// func init() {
// rootCmd.AddCommand(genModel)
// genModel.Flags().StringVarP(&Args, "defMysql", "d", "defMysql", "")
// _ = genModel.MarkFlagRequired("defMysql")
// }
// go run main.go gen-model -d defMysql
var genModel = &cobra.Command{
Use: "gen-model",
Short: "generate models",
Long: "use gorm gen, generate models",
RunE: func(cmd *cobra.Command, args []string) error {
app, cleanfunc, err := container.InitApp()
defer cleanfunc()
if err != nil {
return err
}
dal.GenDefModels(app.DefMysql.DB)
return nil
},
}
func init() {
rootCmd.AddCommand(genModel)
}