gocctl model v20200819 (#18)

* rename snake、came method

* new: generate model from data source

* add change log md

* update model doc

* update  doc

* beauty code
This commit is contained in:
Keson
2020-08-20 10:29:18 +08:00
committed by GitHub
parent 50565c9765
commit db83843558
22 changed files with 295 additions and 139 deletions

View File

@@ -4,6 +4,8 @@ import (
"fmt"
"os"
"github.com/urfave/cli"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/tools/goctl/api/apigen"
"github.com/tal-tech/go-zero/tools/goctl/api/dartgen"
@@ -18,7 +20,6 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/docker"
"github.com/tal-tech/go-zero/tools/goctl/feature"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/command"
"github.com/urfave/cli"
)
var (
@@ -191,25 +192,64 @@ var (
{
Name: "model",
Usage: "generate model code",
Flags: []cli.Flag{
cli.StringFlag{
Name: "src, s",
Usage: "the file path of the ddl source file",
},
cli.StringFlag{
Name: "dir, d",
Usage: "the target dir",
},
cli.BoolFlag{
Name: "cache, c",
Usage: "generate code with cache [optional]",
},
cli.BoolFlag{
Name: "idea",
Usage: "for idea plugin [optional]",
Subcommands: []cli.Command{
{
Name: "mysql",
Usage: `generate mysql model"`,
Subcommands: []cli.Command{
{
Name: "ddl",
Usage: `generate mysql model from ddl"`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "src, s",
Usage: "the file path of the ddl source file",
},
cli.StringFlag{
Name: "dir, d",
Usage: "the target dir",
},
cli.BoolFlag{
Name: "cache, c",
Usage: "generate code with cache [optional]",
},
cli.BoolFlag{
Name: "idea",
Usage: "for idea plugin [optional]",
},
},
Action: command.MysqlDDL,
},
{
Name: "datasource",
Usage: `generate model from datasource"`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "url",
Usage: `the data source of database,like "root:password@tcp(127.0.0.1:3306)/database"`,
},
cli.StringFlag{
Name: "table, t",
Usage: `source table,tables separated by commas,like "user,course"`,
},
cli.BoolFlag{
Name: "cache, c",
Usage: "generate code with cache [optional]",
},
cli.StringFlag{
Name: "dir, d",
Usage: "the target dir",
},
cli.BoolFlag{
Name: "idea",
Usage: "for idea plugin [optional]",
},
},
Action: command.MyDataSource,
},
},
},
},
Action: command.Mysql,
},
{
Name: "config",