增加新特性,并修复一些问题

This commit is contained in:
LLLLancelot
2020-02-28 04:03:08 +08:00
parent 2bd6daaf8d
commit 9e60d56227
17 changed files with 176 additions and 131 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"os"
"strings"
"github.com/xxjwxc/public/tools"
@@ -21,6 +22,8 @@ var foreignKey bool
var funcKey bool
var ui bool
var urlTag string
var tableList string
var outFileName string
var rootCmd = &cobra.Command{
Use: "main",
@@ -72,6 +75,11 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&urlTag, "url", "l", "", "url标签(json,url)")
rootCmd.MarkFlagRequired("url tag")
rootCmd.PersistentFlags().StringVarP(&tableList, "tablelist", "t", "", "目标table列表以','隔开")
rootCmd.MarkFlagRequired("table list")
rootCmd.Flags().StringVar(&outFileName, "outfilename", "", "输出文件名,默认以数据库名称命名")
rootCmd.Flags().IntVar(&mysqlInfo.Port, "port", 3306, "端口号")
}
@@ -111,6 +119,19 @@ func MergeMysqlDbInfo() {
if len(urlTag) > 0 {
config.SetURLTag(urlTag)
}
if len(tableList) > 0 {
m := make(map[string]struct{})
for _, v := range strings.Split(tableList, ",") {
m[v] = struct{}{}
}
config.SetTableList(m)
}
if len(outFileName) > 0 {
if !strings.HasSuffix(outFileName, ".go") {
outFileName += ".go"
}
config.SetOutFileName(outFileName)
}
config.SetMysqlDbInfo(&tmp)