forked from zeromicro/go-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.go
35 lines (30 loc) · 700 Bytes
/
gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package dartgen
import (
"errors"
"strings"
"github.com/zjz894251se/go-zero/core/logx"
"github.com/zjz894251se/go-zero/tools/goctl/api/parser"
"github.com/urfave/cli"
)
func DartCommand(c *cli.Context) error {
apiFile := c.String("api")
dir := c.String("dir")
if len(apiFile) == 0 {
return errors.New("missing -api")
}
if len(dir) == 0 {
return errors.New("missing -dir")
}
api, err := parser.Parse(apiFile)
if err != nil {
return err
}
if !strings.HasSuffix(dir, "/") {
dir = dir + "/"
}
api.Info.Title = strings.Replace(apiFile, ".api", "", -1)
logx.Must(genData(dir+"data/", api))
logx.Must(genApi(dir+"api/", api))
logx.Must(genVars(dir + "vars/"))
return nil
}