mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 17:52:49 +08:00
ee19fb736b
* feature: refactor api parse to g4 * new g4 parser * add CHANGE_LOG.MD * refactor * fix byte bug * refactor * optimized * optimized * revert * update readme.md * update readme.md * update readme.md * update readme.md * remove no need * fix java gen * add upgrade * resolve confilits Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
39 lines
592 B
Go
39 lines
592 B
Go
package ktgen
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
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)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
|
|
e = genBase(dir, pkg, api)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = genApi(dir, pkg, api)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
return nil
|
|
}
|