genmongocmd.go 483 B

123456789101112131415161718192021222324252627282930
  1. package mongomodel
  2. import (
  3. "errors"
  4. "fmt"
  5. "zero/core/lang"
  6. "zero/tools/goctl/model/mongomodel/gen"
  7. "github.com/logrusorgru/aurora"
  8. "github.com/urfave/cli"
  9. )
  10. func ModelCommond(c *cli.Context) error {
  11. src := c.String("src")
  12. cache := c.String("cache")
  13. if len(src) == 0 {
  14. return errors.New("missing -src")
  15. }
  16. var needCache bool
  17. if cache == "yes" {
  18. needCache = true
  19. }
  20. lang.Must(gen.GenMongoModel(src, needCache))
  21. fmt.Println(aurora.Green("Done."))
  22. return nil
  23. }