go-zero/tools/goctl/api/ktgen/cmd.go

40 lines
647 B
Go
Raw Normal View History

2020-08-14 09:02:32 +08:00
package ktgen
import (
"errors"
2020-08-14 10:35:35 +08:00
2020-08-14 09:02:32 +08:00
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
"github.com/urfave/cli"
)
// KtCommand the generate kotlin code command entrance
2020-08-14 09:02:32 +08:00
func KtCommand(c *cli.Context) error {
apiFile := c.String("api")
if apiFile == "" {
return errors.New("missing -api")
}
dir := c.String("dir")
if dir == "" {
return errors.New("missing -dir")
}
pkg := c.String("pkg")
if pkg == "" {
return errors.New("missing -pkg")
}
api, e := parser.Parse(apiFile)
2020-08-14 10:35:35 +08:00
if e != nil {
return e
2020-08-14 09:02:32 +08:00
}
2020-08-14 19:25:34 +08:00
e = genBase(dir, pkg, api)
if e != nil {
return e
}
e = genApi(dir, pkg, api)
if e != nil {
return e
}
2020-08-14 09:02:32 +08:00
return nil
}