-
Notifications
You must be signed in to change notification settings - Fork 0
/
goctl-rest-client.go
62 lines (59 loc) · 1.3 KB
/
goctl-rest-client.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
54
55
56
57
58
59
60
61
62
package main
import (
"fmt"
"github.com/mengdj/goctl-rest-client/generate"
"github.com/urfave/cli/v2"
"github.com/zeromicro/go-zero/tools/goctl/plugin"
"os"
"runtime"
)
var (
author = []*cli.Author{
&cli.Author{
Name: "mengdj",
Email: "[email protected]",
},
}
commands = []*cli.Command{
{
Name: "rest-client",
Usage: "generates rest-client",
Action: func(context *cli.Context) error {
plugin, err := plugin.NewPlugin()
if nil != err {
return err
}
return generate.Do(plugin, context)
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "package",
Usage: "the package of rest-client",
Value: "client",
Required: false,
},
&cli.StringFlag{
Name: "destination",
Usage: "destination address,for example www.baidu.com or service",
Required: true,
},
&cli.StringFlag{
Name: "file",
Usage: "target file",
Required: false,
Value: "client.go",
},
},
},
}
)
func main() {
app := cli.NewApp()
app.Authors = author
app.Usage = "a plugin of goctl to generate rest-client"
app.Version = fmt.Sprintf("%s %s/%s", generate.Version, runtime.GOOS, runtime.GOARCH)
app.Commands = commands
if err := app.Run(os.Args); err != nil {
fmt.Printf("goctl-rest-client: %+v\n", err)
}
}