2020-07-04 14:58:03 +00:00
|
|
|
// Copyright 2013 bee authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"): you may
|
|
|
|
// not use this file except in compliance with the License. You may obtain
|
|
|
|
// a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing permissions and limitations
|
|
|
|
// under the License.
|
|
|
|
package beegopro
|
|
|
|
|
|
|
|
import (
|
2020-10-09 15:33:58 +00:00
|
|
|
"strings"
|
|
|
|
|
2020-12-16 05:20:41 +00:00
|
|
|
"github.com/beego/bee/v2/cmd/commands"
|
|
|
|
"github.com/beego/bee/v2/internal/app/module/beegopro"
|
|
|
|
"github.com/beego/bee/v2/logger"
|
2020-07-04 14:58:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var CmdBeegoPro = &commands.Command{
|
|
|
|
UsageLine: "pro [command]",
|
|
|
|
Short: "Source code generator",
|
|
|
|
Long: ``,
|
|
|
|
Run: BeegoPro,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
CmdBeegoPro.Flag.Var(&beegopro.SQL, "sql", "sql file path")
|
2020-07-11 09:44:39 +00:00
|
|
|
CmdBeegoPro.Flag.Var(&beegopro.SQLMode, "sqlmode", "sql mode")
|
|
|
|
CmdBeegoPro.Flag.Var(&beegopro.SQLModePath, "sqlpath", "sql mode path")
|
2021-01-07 18:09:11 +00:00
|
|
|
CmdBeegoPro.Flag.Var(&beegopro.GitRemotePath, "url", "git remote path")
|
2020-07-04 14:58:03 +00:00
|
|
|
commands.AvailableCommands = append(commands.AvailableCommands, CmdBeegoPro)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BeegoPro(cmd *commands.Command, args []string) int {
|
|
|
|
if len(args) < 1 {
|
|
|
|
beeLogger.Log.Fatal("Command is missing")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(args) >= 2 {
|
|
|
|
cmd.Flag.Parse(args[1:])
|
|
|
|
}
|
|
|
|
|
|
|
|
gcmd := args[0]
|
|
|
|
switch gcmd {
|
|
|
|
case "gen":
|
|
|
|
beegopro.DefaultBeegoPro.Run()
|
2020-09-10 11:35:44 +00:00
|
|
|
case "toml":
|
|
|
|
beegopro.DefaultBeegoPro.InitToml()
|
2020-07-04 14:58:03 +00:00
|
|
|
case "config":
|
|
|
|
beegopro.DefaultBeegoPro.GenConfig()
|
|
|
|
case "migration":
|
|
|
|
beegopro.DefaultBeegoPro.Migration(args)
|
|
|
|
default:
|
|
|
|
beeLogger.Log.Fatal("Command is missing")
|
|
|
|
}
|
|
|
|
beeLogger.Log.Successf("%s successfully generated!", strings.Title(gcmd))
|
|
|
|
return 0
|
|
|
|
}
|