goctl-swagger/main.go

46 lines
856 B
Go
Raw Normal View History

2021-01-01 20:30:52 +08:00
package main
import (
"fmt"
"os"
"runtime"
2021-07-30 14:33:10 +08:00
"github.com/urfave/cli/v2"
2022-04-19 09:43:07 +08:00
"github.com/zeromicro/goctl-swagger/action"
2021-01-01 20:30:52 +08:00
)
var (
version = "20220215"
2021-01-01 20:30:52 +08:00
commands = []*cli.Command{
2021-01-03 16:11:59 +08:00
{
2021-01-01 20:30:52 +08:00
Name: "swagger",
Usage: "generates swagger.json",
Action: action.Generator,
2021-01-16 11:53:17 +08:00
Flags: []cli.Flag{
2021-07-30 14:33:10 +08:00
&cli.StringFlag{
Name: "host",
Usage: "api request address",
},
&cli.StringFlag{
Name: "basepath",
Usage: "url request prefix",
},
2021-01-16 11:53:17 +08:00
&cli.StringFlag{
Name: "filename",
Usage: "swagger save file name",
},
},
2021-01-01 20:30:52 +08:00
},
}
)
func main() {
app := cli.NewApp()
app.Usage = "a plugin of goctl to generate swagger.json"
app.Version = fmt.Sprintf("%s %s/%s", version, runtime.GOOS, runtime.GOARCH)
app.Commands = commands
if err := app.Run(os.Args); err != nil {
fmt.Printf("goctl-swagger: %+v\n", err)
}
}