Skip to content

Commit

Permalink
Upgrade module github.com/urfave/cli/ from v1.22.4 to v2.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiang-fit2cloud committed Jun 29, 2020
1 parent 1db4d60 commit ecb3ed4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gotty/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ require (
github.com/kr/pty v1.1.8
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/urfave/cli v1.22.4
github.com/urfave/cli/v2 v2.2.0
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
)
4 changes: 2 additions & 2 deletions gotty/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
16 changes: 8 additions & 8 deletions gotty/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"syscall"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"

"github.com/KubeOperator/webkubectl/gotty/backend/localcommand"
"github.com/KubeOperator/webkubectl/gotty/server"
Expand Down Expand Up @@ -40,16 +40,16 @@ func main() {

app.Flags = append(
cliFlags,
cli.StringFlag{
&cli.StringFlag{
Name: "config",
Value: "~/.gotty",
Usage: "Config file path",
EnvVar: "GOTTY_CONFIG",
EnvVars: []string{"GOTTY_CONFIG"},
},
)

app.Action = func(c *cli.Context) {
if len(c.Args()) == 0 {
app.Action = func(c *cli.Context) error {
if c.Args().Len() == 0 {
msg := "Error: No command given."
cli.ShowAppHelp(c)
exit(fmt.Errorf(msg), 1)
Expand All @@ -66,7 +66,7 @@ func main() {
exit(err, 6)
}

args := c.Args()
args := c.Args().Slice()
factory, err := localcommand.NewFactory(args[0], args[1:], backendOptions)
if err != nil {
exit(err, 3)
Expand All @@ -87,7 +87,7 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
gCtx, gCancel := context.WithCancel(context.Background())
log.Println("Welcome to use webkubectl.")
log.Printf("GoTTY is starting with command: %s", strings.Join(args, " "))
log.Printf("GoTTY is starting with command: %s", strings.Join(c.Args().Slice(), " "))

errs := make(chan error, 1)
go func() {
Expand All @@ -99,7 +99,7 @@ func main() {
fmt.Printf("Error: %s\n", err)
exit(err, 8)
}

return nil
}
app.Run(os.Args)
}
Expand Down
14 changes: 7 additions & 7 deletions gotty/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"strings"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
"github.com/fatih/structs"
)

Expand All @@ -30,24 +30,24 @@ func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[strin

switch field.Kind() {
case reflect.String:
flags = append(flags, cli.StringFlag{
flags = append(flags, &cli.StringFlag{
Name: flagName,
Value: field.Value().(string),
Usage: flagDescription,
EnvVar: envName,
})
case reflect.Bool:
flags = append(flags, cli.BoolFlag{
flags = append(flags, &cli.BoolFlag{
Name: flagName,
Usage: flagDescription,
EnvVar: envName,
EnvVars: []string{envName},

})
case reflect.Int:
flags = append(flags, cli.IntFlag{
flags = append(flags, &cli.IntFlag{
Name: flagName,
Value: field.Value().(int),
Usage: flagDescription,
EnvVar: envName,
EnvVars: []string{envName},
})
}
}
Expand Down

0 comments on commit ecb3ed4

Please sign in to comment.