diff --git a/cmd/gen_enum.go b/cmd/gen_enum.go index 6cf3fcf..1f5ae0e 100644 --- a/cmd/gen_enum.go +++ b/cmd/gen_enum.go @@ -16,9 +16,10 @@ import ( func CommandGenEnum(root *cobra.Command) { cmd := &cobra.Command{ - Use: "enum", - Short: "Generate enums", - RunE: commandGenEnumE, + Use: "enum", + Aliases: []string{"e"}, + Short: "Generate enums", + RunE: commandGenEnumE, } cmd.Flags().BoolP("flag", "f", true, "Flag enum values") diff --git a/cmd/gen_model.go b/cmd/gen_model.go index b054f8e..a6fde0c 100644 --- a/cmd/gen_model.go +++ b/cmd/gen_model.go @@ -19,9 +19,10 @@ import ( func CommandGenModel(root *cobra.Command) { cmd := &cobra.Command{ - Use: "model", - Short: "Generate jet models", - RunE: commandGenModelE, + Use: "model", + Aliases: []string{"m"}, + Short: "Generate jet models", + RunE: commandGenModelE, } root.AddCommand(cmd) diff --git a/cmd/gen_provider.go b/cmd/gen_provider.go index 905a0d5..3a61566 100644 --- a/cmd/gen_provider.go +++ b/cmd/gen_provider.go @@ -28,8 +28,9 @@ func getTypePkgName(typ string) string { func CommandGenProvider(root *cobra.Command) { cmd := &cobra.Command{ - Use: "provider", - Short: "Generate providers", + Use: "provider", + Aliases: []string{"p"}, + Short: "Generate providers", Long: ` // @provider // @provider:[except|only] [returnType] [group] diff --git a/cmd/migrate.go b/cmd/migrate.go index a7239f6..dfd6bcd 100644 --- a/cmd/migrate.go +++ b/cmd/migrate.go @@ -14,8 +14,9 @@ import ( // migrate func CommandMigrate(root *cobra.Command) { cmd := &cobra.Command{ - Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]", - RunE: commandMigrate, + Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]", + Aliases: []string{"m"}, + RunE: commandMigrate, } cmd.Flags().StringP("config", "c", "config.toml", "database config file") diff --git a/cmd/new_module.go b/cmd/new_module.go index e844299..b6dddf1 100644 --- a/cmd/new_module.go +++ b/cmd/new_module.go @@ -18,10 +18,11 @@ import ( func CommandNewModule(root *cobra.Command) { cmd := &cobra.Command{ - Use: "module", - Short: "new module", - Args: cobra.ExactArgs(1), - RunE: commandNewModuleE, + Use: "module", + Aliases: []string{"m"}, + Short: "new module", + Args: cobra.ExactArgs(1), + RunE: commandNewModuleE, } root.AddCommand(cmd) diff --git a/cmd/new_project.go b/cmd/new_project.go index 8f2bd16..5286277 100644 --- a/cmd/new_project.go +++ b/cmd/new_project.go @@ -24,9 +24,10 @@ func isValidGoPackageName(name string) bool { func CommandNewProject(root *cobra.Command) { cmd := &cobra.Command{ - Use: "project", - Short: "new project", - RunE: commandNewProjectE, + Use: "project", + Aliases: []string{"p"}, + Short: "new project", + RunE: commandNewProjectE, } root.AddCommand(cmd) diff --git a/templates/project/pkg/pg/db.go.tpl b/templates/project/pkg/pg/db.go.tpl index 98c1ea3..8bda8af 100644 --- a/templates/project/pkg/pg/db.go.tpl +++ b/templates/project/pkg/pg/db.go.tpl @@ -5,13 +5,13 @@ import ( "database/sql" "fmt" - "{{.ModuleName}}/pkg/consts" - "github.com/go-jet/jet/v2/qrm" ) +const CtxDB = "__db__tx:" + func FromContext(ctx context.Context, db *sql.DB) qrm.DB { - if tx, ok := ctx.Value(consts.CtxKeyTx).(*sql.Tx); ok { + if tx, ok := ctx.Value(CtxDB).(*sql.Tx); ok { return tx } return db