From 95ed5bbdd4e7a2d6af94e7858901062439af71e3 Mon Sep 17 00:00:00 2001 From: hupeh Date: Thu, 12 Oct 2023 19:09:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/commands/create_entity.go | 11 +++++++++++ scripts/gen/gen.go | 16 ++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 cmd/commands/create_entity.go diff --git a/cmd/commands/create_entity.go b/cmd/commands/create_entity.go new file mode 100644 index 0000000..376d589 --- /dev/null +++ b/cmd/commands/create_entity.go @@ -0,0 +1,11 @@ +package commands + +import ( + "github.com/urfave/cli/v2" +) + +func CreateEntity(c *cli.Context) error { + args := c.Args() + + args.Get(0) +} diff --git a/scripts/gen/gen.go b/scripts/gen/gen.go index c75521d..ead4ae5 100644 --- a/scripts/gen/gen.go +++ b/scripts/gen/gen.go @@ -55,10 +55,9 @@ func main() { if err != nil { panic(err) } - os.MkdirAll("../internal/repositories", os.ModePerm) + _ = os.MkdirAll("../internal/repositories", os.ModePerm) var camels []string var pascals []string - var iocStr string var createdCount int for _, dir := range dirs { name := dir.Name() @@ -79,7 +78,6 @@ func main() { fmt.Println("跳过 " + dir.Name()) continue } - iocStr += "\tioc.MustSingleton(New" + pascal + "Repository)\n" repository := "../internal/repositories/" + dir.Name() if PathExists(repository) { fmt.Println("跳过 " + dir.Name()) @@ -87,21 +85,11 @@ func main() { code := strings.ReplaceAll(repoStub, "{{pascal}}", pascal) code = strings.ReplaceAll(code, "{{camel}}", camel) code = strings.ReplaceAll(code, "{{label}}", label) - os.WriteFile("../internal/repositories/"+dir.Name(), []byte(code), os.ModePerm) + _ = os.WriteFile("../internal/repositories/"+dir.Name(), []byte(code), os.ModePerm) fmt.Println("创建 " + dir.Name()) createdCount++ } } - - if createdCount > 0 { - os.WriteFile("../internal/repositories/ioc.go", []byte(`package repositories - -import "sorbet/pkg/ioc" - -func init() { -`+iocStr+`} -`), os.ModePerm) - } } func PathExists(path string) bool {