goctl-swagger/action/action.go

23 lines
401 B
Go
Raw Normal View History

2021-01-01 20:30:52 +08:00
package action
import (
2021-01-16 20:44:15 +08:00
plugin2 "github.com/tal-tech/go-zero/tools/goctl/plugin"
2021-01-01 20:30:52 +08:00
"github.com/urfave/cli/v2"
"github.com/zeromicro/goctl-swagger/generate"
)
func Generator(ctx *cli.Context) error {
2021-01-16 20:44:15 +08:00
fileName := ctx.String("filename")
2021-01-01 20:30:52 +08:00
2021-01-16 20:44:15 +08:00
if len(fileName) == 0 {
fileName = "rest.swagger.json"
2021-01-16 11:53:17 +08:00
}
2021-01-16 20:44:15 +08:00
p, err := plugin2.NewPlugin()
2021-01-01 20:30:52 +08:00
if err != nil {
return err
}
2021-01-16 20:44:15 +08:00
return generate.Do(fileName, p)
2021-01-01 20:30:52 +08:00
}