forked from swaggo/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (50 loc) · 1.22 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"os"
"github.com/swaggo/swag"
"github.com/swaggo/swag/gen"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Version = swag.Version
app.Usage = "Automatically generate RESTful API documentation with Swagger 2.0 for Go."
app.Commands = []cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "Create docs.go",
Action: func(c *cli.Context) error {
dir := c.String("dir")
mainAPIFile := c.String("generalInfo")
swaggerConfDir := c.String("swagger")
strategy := c.String("propertyStrategy")
gen.New().Build(dir, mainAPIFile, swaggerConfDir, strategy)
return nil
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "generalInfo, g",
Value: "main.go",
Usage: "Go file path in which 'swagger general API Info' is written",
},
cli.StringFlag{
Name: "dir, d",
Value: "./",
Usage: "Directory you want to parse",
},
cli.StringFlag{
Name: "swagger, s",
Value: "./docs/swagger",
Usage: "Output the swagger conf for json and yaml",
},
cli.StringFlag{
Name: "propertyStrategy, p",
Value: "",
Usage: "Property Naming Strategy like snakecase",
},
},
},
}
app.Run(os.Args)
}