templates.go 634 B

123456789101112131415161718192021222324252627282930313233
  1. package tpl
  2. import (
  3. "fmt"
  4. "github.com/logrusorgru/aurora"
  5. "github.com/tal-tech/go-zero/core/errorx"
  6. "github.com/tal-tech/go-zero/tools/goctl/api/gogen"
  7. "github.com/tal-tech/go-zero/tools/goctl/util"
  8. "github.com/urfave/cli"
  9. )
  10. const templateParentPath = "/"
  11. func GenTemplates(ctx *cli.Context) error {
  12. if err := errorx.Chain(
  13. func() error {
  14. return gogen.GenTemplates(ctx)
  15. },
  16. ); err != nil {
  17. return err
  18. }
  19. dir, err := util.GetTemplateDir(templateParentPath)
  20. if err != nil {
  21. return err
  22. }
  23. fmt.Printf("Templates are generated in %s, %s\n", aurora.Green(dir),
  24. aurora.Red("edit on your risk!"))
  25. return nil
  26. }