From 40e6b2b0f1273b65689262fb5903c4f8ada6e553 Mon Sep 17 00:00:00 2001 From: OmegaMT Date: Mon, 4 Jul 2022 21:01:55 +0800 Subject: [PATCH] fix gf run custom arguments and gf gen dao specify config file path (#1879) --- cmd/gf/internal/cmd/cmd_gen_dao.go | 1 - cmd/gf/internal/cmd/cmd_run.go | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/gf/internal/cmd/cmd_gen_dao.go b/cmd/gf/internal/cmd/cmd_gen_dao.go index 8cbeaf097..6d8ae5af8 100644 --- a/cmd/gf/internal/cmd/cmd_gen_dao.go +++ b/cmd/gf/internal/cmd/cmd_gen_dao.go @@ -48,7 +48,6 @@ CONFIGURATION SUPPORT - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" tables: "order,products" jsonCase: "CamelLower" - - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/primary" path: "./my-app" prefix: "primary_" diff --git a/cmd/gf/internal/cmd/cmd_run.go b/cmd/gf/internal/cmd/cmd_run.go index 2187c13b9..627db22fd 100644 --- a/cmd/gf/internal/cmd/cmd_run.go +++ b/cmd/gf/internal/cmd/cmd_run.go @@ -13,7 +13,6 @@ import ( "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" - "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gtag" ) @@ -47,6 +46,7 @@ which compiles and runs the go codes asynchronously when codes change. cRunFileBrief = `building file path.` cRunPathBrief = `output directory path for built binary file. it's "manifest/output" in default` cRunExtraBrief = `the same options as "go run"/"go build" except some options as follows defined` + cRunArgsBrief = `custom arguments for your process` ) var ( @@ -62,6 +62,7 @@ func init() { `cRunFileBrief`: cRunFileBrief, `cRunPathBrief`: cRunPathBrief, `cRunExtraBrief`: cRunExtraBrief, + `cRunArgsBrief`: cRunArgsBrief, }) } @@ -71,6 +72,7 @@ type ( File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"` Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"` Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"` + Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"` } cRunOutput struct{} ) @@ -85,6 +87,7 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err File: in.File, Path: in.Path, Options: in.Extra, + Args: in.Args, } dirty := gtype.NewBool() _, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) { @@ -150,9 +153,9 @@ func (app *cRunApp) Run(ctx context.Context) { if runtime.GOOS == "windows" { // Special handling for windows platform. // DO NOT USE "cmd /c" command. - process = gproc.NewProcess(outputPath, gstr.SplitAndTrim(" ", app.Args)) + process = gproc.NewProcess(runCommand, nil) } else { - process = gproc.NewProcessCmd(outputPath, gstr.SplitAndTrim(" ", app.Args)) + process = gproc.NewProcessCmd(runCommand, nil) } if pid, err := process.Start(ctx); err != nil { mlog.Printf("build running error: %s", err.Error())