cmd.go 647 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. // KtCommand the generate kotlin code command entrance
  8. func KtCommand(c *cli.Context) error {
  9. apiFile := c.String("api")
  10. if apiFile == "" {
  11. return errors.New("missing -api")
  12. }
  13. dir := c.String("dir")
  14. if dir == "" {
  15. return errors.New("missing -dir")
  16. }
  17. pkg := c.String("pkg")
  18. if pkg == "" {
  19. return errors.New("missing -pkg")
  20. }
  21. api, e := parser.Parse(apiFile)
  22. if e != nil {
  23. return e
  24. }
  25. e = genBase(dir, pkg, api)
  26. if e != nil {
  27. return e
  28. }
  29. e = genApi(dir, pkg, api)
  30. if e != nil {
  31. return e
  32. }
  33. return nil
  34. }