-
Notifications
You must be signed in to change notification settings - Fork 15
/
cmd.go
118 lines (95 loc) · 5.33 KB
/
cmd.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package extra
import (
"github.com/suyuan32/goctls/extra/ent/importschema"
"github.com/suyuan32/goctls/extra/ent/localmixin"
"github.com/suyuan32/goctls/extra/ent/schema"
"github.com/suyuan32/goctls/extra/ent/template"
"github.com/suyuan32/goctls/extra/i18n"
"github.com/suyuan32/goctls/extra/initlogic"
"github.com/suyuan32/goctls/extra/logviewer"
"github.com/suyuan32/goctls/extra/makefile"
"github.com/suyuan32/goctls/extra/middleware"
"github.com/suyuan32/goctls/extra/proto2api"
"github.com/suyuan32/goctls/internal/cobrax"
)
var (
ExtraCmd = cobrax.NewCommand("extra")
i18nCmd = cobrax.NewCommand("i18n", cobrax.WithRunE(i18n.Gen))
initCmd = cobrax.NewCommand("init_code", cobrax.WithRunE(initlogic.Gen))
entCmd = cobrax.NewCommand("ent")
templateCmd = cobrax.NewCommand("template", cobrax.WithRunE(template.GenTemplate))
mixinCmd = cobrax.NewCommand("mixin", cobrax.WithRunE(localmixin.GenLocalMixin))
entImportCmd = cobrax.NewCommand("import", cobrax.WithRunE(importschema.Gen))
entSchemaCmd = cobrax.NewCommand("schema", cobrax.WithRunE(schema.GenSchema))
proto2apiCmd = cobrax.NewCommand("proto2api", cobrax.WithRunE(proto2api.Gen))
makefileCmd = cobrax.NewCommand("makefile", cobrax.WithRunE(makefile.Gen))
logViewerCmd = cobrax.NewCommand("view_log", cobrax.WithRunE(logviewer.Gen))
)
func init() {
var (
i18nCmdFlags = i18nCmd.Flags()
initCmdFlags = initCmd.Flags()
templateCmdFlags = templateCmd.Flags()
mixinCmdFlags = mixinCmd.Flags()
makefileCmdFlags = makefileCmd.Flags()
entImportCmdFlags = entImportCmd.Flags()
proto2apiCmdFlags = proto2apiCmd.Flags()
logViewerCmdFlags = logViewerCmd.Flags()
entSchemaCmdFlags = entSchemaCmd.Flags()
)
i18nCmdFlags.StringVarP(&i18n.VarStringTarget, "target", "t")
i18nCmdFlags.StringVarP(&i18n.VarStringModelName, "model_name", "m")
i18nCmdFlags.StringVarP(&i18n.VarStringModelNameZh, "model_name_zh", "z")
i18nCmdFlags.StringVarP(&i18n.VarStringOutputDir, "output", "o")
initCmdFlags.StringVarP(&initlogic.VarStringTarget, "target", "t")
initCmdFlags.StringVarP(&initlogic.VarStringModelName, "model_name", "m")
initCmdFlags.StringVarP(&initlogic.VarStringRoutePrefix, "route_prefix", "p")
initCmdFlags.StringVarPWithDefaultValue(&initlogic.VarStringOutputPath, "output", "o", ".")
initCmdFlags.StringVarPWithDefaultValue(&initlogic.VarServiceName, "service_name", "n", "Other")
initCmdFlags.StringVarPWithDefaultValue(&initlogic.VarStringStyle, "style", "s", "go_zero")
templateCmdFlags.StringVarP(&template.VarStringDir, "dir", "d")
templateCmdFlags.StringVarP(&template.VarStringAdd, "add", "a")
templateCmdFlags.BoolVarP(&template.VarBoolList, "list", "l")
templateCmdFlags.BoolVarP(&template.VarBoolUpdate, "update", "u")
makefileCmdFlags.StringVarP(&makefile.VarStringServiceName, "service_name", "n")
makefileCmdFlags.StringVarP(&makefile.VarStringStyle, "style", "s")
makefileCmdFlags.StringVarP(&makefile.VarStringDir, "dir", "d")
makefileCmdFlags.StringVarP(&makefile.VarStringServiceType, "service_type", "t")
makefileCmdFlags.BoolVarP(&makefile.VarBoolI18n, "i18n", "i")
makefileCmdFlags.BoolVarP(&makefile.VarBoolEnt, "ent", "e")
proto2apiCmdFlags.StringVarP(&proto2api.VarStringApiPath, "api_path", "a")
proto2apiCmdFlags.StringVarP(&proto2api.VarStringProtoPath, "proto_path", "p")
proto2apiCmdFlags.StringVarP(&proto2api.VarStringModelName, "model_name", "m")
proto2apiCmdFlags.StringVarP(&proto2api.VarStringGroupName, "group_name", "g")
proto2apiCmdFlags.BoolVarWithDefaultValue(&proto2api.VarBoolMultiple, "multiple", false)
proto2apiCmdFlags.StringVarPWithDefaultValue(&proto2api.VarStringJsonStyle, "json_style", "j", "goZero")
mixinCmdFlags.StringVarP(&localmixin.VarStringDir, "dir", "d")
mixinCmdFlags.StringVarP(&localmixin.VarStringAdd, "add", "a")
mixinCmdFlags.BoolVarP(&localmixin.VarBoolList, "list", "l")
mixinCmdFlags.BoolVarP(&localmixin.VarBoolUpdate, "update", "u")
entImportCmdFlags.StringVarP(&importschema.VarStringDSN, "dsn", "d")
entImportCmdFlags.StringVarP(&importschema.VarStringTables, "tables", "t")
entImportCmdFlags.StringVarP(&importschema.VarStringOutputDir, "output", "o")
//entImportCmdFlags.BoolVarP(&importschema.VarBoolAutoMixin, "auto_mixin", "a")
entImportCmdFlags.StringVarP(&importschema.VarStringExcludeTables, "exclude_tables", "e")
entSchemaCmdFlags.StringVarP(&schema.VarStringModelName, "model_name", "m")
logViewerCmdFlags.StringVarP(&logviewer.VarStringFilePath, "path", "p")
logViewerCmdFlags.StringVarP(&logviewer.VarStringWorkspaceSetting, "workspace_setting", "k")
logViewerCmdFlags.StringVarP(&logviewer.VarStringWorkspace, "workspace", "w")
logViewerCmdFlags.StringVarP(&logviewer.VarStringLogType, "log_type", "t")
logViewerCmdFlags.BoolVarP(&logviewer.VarBoolResetWorkspace, "reset_workspace", "r")
logViewerCmdFlags.BoolVarP(&logviewer.VarBoolList, "list", "l")
logViewerCmdFlags.IntVarPWithDefaultValue(&logviewer.VarIntMessageCapacity, "size", "s", 10)
logViewerCmdFlags.StringVarP(&logviewer.VarStringRemoveConfig, "delete_config", "d")
ExtraCmd.AddCommand(i18nCmd)
ExtraCmd.AddCommand(initCmd)
entCmd.AddCommand(templateCmd)
entCmd.AddCommand(mixinCmd)
entCmd.AddCommand(entImportCmd)
entCmd.AddCommand(entSchemaCmd)
ExtraCmd.AddCommand(entCmd)
ExtraCmd.AddCommand(makefileCmd)
ExtraCmd.AddCommand(proto2apiCmd)
ExtraCmd.AddCommand(logViewerCmd)
ExtraCmd.AddCommand(middleware.MiddlewareCmd)
}