goctl-swagger/action/action.go

27 lines
592 B
Go
Raw Normal View History

2021-01-01 20:30:52 +08:00
package action
import (
2024-12-18 12:08:19 +08:00
"github.com/devttl/goctl-swagger/generate"
2021-01-01 20:30:52 +08:00
"github.com/urfave/cli/v2"
2022-02-14 10:32:28 +08:00
"github.com/zeromicro/go-zero/tools/goctl/plugin"
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")
2023-11-19 12:39:59 +08:00
schemes := ctx.String("schemes")
2024-12-18 12:08:19 +08:00
pack := ctx.String("pack")
response := ctx.String("response")
return generate.Do(fileName, host, basepath, schemes, pack, response, p)
2021-01-01 20:30:52 +08:00
}