-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.go
57 lines (52 loc) · 1.34 KB
/
upgrade.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
package upgrade
import (
"github.com/sado0823/go-kitx/cmd/kitx/internal"
"github.com/AlecAivazis/survey/v2"
"github.com/urfave/cli/v2"
)
var (
flagAll = "all"
)
func Cmd() *cli.Command {
return &cli.Command{
Name: "upgrade",
Aliases: []string{"u"},
Usage: "upgrade kitx tools",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: flagAll,
DefaultText: "true",
Usage: "update all tools including protoc-gen-go*",
Aliases: []string{"a"},
},
},
Action: func(cCtx *cli.Context) error {
answer := false
confirm := &survey.Confirm{
Message: "do you want to upgrade kitx tools ❓",
Help: "upgrade kitx、 protoc-gen-go-http-kitx、 protoc-gen-go-errors-kitx",
}
if err := survey.AskOne(confirm, &answer); err != nil {
return err
}
if !answer {
return nil
}
var (
toInstall = []string{
"github.com/sado0823/go-kitx/cmd/kitx@latest",
"github.com/sado0823/go-kitx/cmd/protoc-gen-go-http-kitx@latest",
"github.com/sado0823/go-kitx/cmd//protoc-gen-go-errors-kitx@latest",
}
addAll = cCtx.Bool(flagAll)
)
if addAll {
toInstall = append([]string{
"google.golang.org/protobuf/cmd/protoc-gen-go@latest",
"google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest",
}, toInstall...)
}
return internal.GoInstall(toInstall...)
},
}
}