cmd.go 592 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package ktgen
  2. import (
  3. "errors"
  4. "github.com/tal-tech/go-zero/tools/goctl/api/parser"
  5. "github.com/urfave/cli"
  6. )
  7. func KtCommand(c *cli.Context) error {
  8. apiFile := c.String("api")
  9. if apiFile == "" {
  10. return errors.New("missing -api")
  11. }
  12. dir := c.String("dir")
  13. if dir == "" {
  14. return errors.New("missing -dir")
  15. }
  16. pkg := c.String("pkg")
  17. if pkg == "" {
  18. return errors.New("missing -pkg")
  19. }
  20. api, e := parser.Parse(apiFile)
  21. if e != nil {
  22. return e
  23. }
  24. e = genBase(dir, pkg, api)
  25. if e != nil {
  26. return e
  27. }
  28. e = genApi(dir, pkg, api)
  29. if e != nil {
  30. return e
  31. }
  32. return nil
  33. }