2021-01-01 20:30:52 +08:00
|
|
|
package action
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/urfave/cli/v2"
|
2022-02-14 10:32:28 +08:00
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/plugin"
|
2022-04-19 09:43:07 +08:00
|
|
|
"github.com/zeromicro/goctl-swagger/generate"
|
2021-01-01 20:30:52 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-02-14 10:32:28 +08:00
|
|
|
p, err := plugin.NewPlugin()
|
2021-01-01 20:30:52 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-07-30 14:33:10 +08:00
|
|
|
basepath := ctx.String("basepath")
|
|
|
|
host := ctx.String("host")
|
|
|
|
return generate.Do(fileName, host, basepath, p)
|
2021-01-01 20:30:52 +08:00
|
|
|
}
|