Skip to content

Commit 05d1f96

Browse files
committed
Bump urfave/cli to v2
1 parent ca9f6c2 commit 05d1f96

File tree

9 files changed

+37
-29
lines changed

9 files changed

+37
-29
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Here is the typical usage pattern in `main.go`:
4545
package main
4646

4747
import (
48-
"github.com/urfave/cli"
48+
"github.com/urfave/cli/v2"
4949
"github.com/gruntwork-io/go-commons/entrypoint"
5050
"github.com/gruntwork-io/go-commons/version"
5151
)
@@ -56,7 +56,12 @@ func main() {
5656
app := entrypoint.NewApp()
5757

5858
app.Name = "my-app"
59-
app.Author = "Gruntwork <www.gruntwork.io>"
59+
app.Authors = []*cli.Author{
60+
{
61+
Name: "Gruntwork",
62+
Email: "www.gruntwork.io",
63+
},
64+
}
6065

6166
// Set the version number from your app from the Version variable that is passed in at build time in `version` package
6267
// for more understanding see github.com/gruntwork-io/go-commons/version

entrypoint/assertions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/urfave/cli"
7+
"github.com/urfave/cli/v2"
88
)
99

1010
type RequiredArgsError struct {

entrypoint/assertions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/assert"
8-
"github.com/urfave/cli"
8+
"github.com/urfave/cli/v2"
99
)
1010

1111
func TestStringFlagRequiredOnMissingFlag(t *testing.T) {
@@ -54,7 +54,7 @@ func TestEnvironmentVarRequiredOnSetEnvVar(t *testing.T) {
5454
func createSampleAppWithRequiredFlag() *cli.App {
5555
app := cli.NewApp()
5656
app.Flags = []cli.Flag{
57-
cli.StringFlag{
57+
&cli.StringFlag{
5858
Name: "the-answer-to-all-problems",
5959
},
6060
}

entrypoint/entrypoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/urfave/cli"
7+
"github.com/urfave/cli/v2"
88

99
"github.com/gruntwork-io/go-commons/errors"
1010
"github.com/gruntwork-io/go-commons/logging"

entrypoint/entrypoint_test.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"fmt"
66
"testing"
77

8-
"github.com/gruntwork-io/go-commons/errors"
98
"github.com/stretchr/testify/assert"
10-
"github.com/urfave/cli"
9+
"github.com/urfave/cli/v2"
10+
11+
"github.com/gruntwork-io/go-commons/errors"
1112
)
1213

1314
func TestEntrypointGetExitCode(t *testing.T) {
@@ -54,8 +55,8 @@ func TestEntrypointNewAppWrapsAppHelpPrinter(t *testing.T) {
5455
app.Writer = fakeStdout
5556
args := []string{"houston", "help"}
5657
err := app.Run(args)
57-
assert.Nil(t, err)
58-
assert.Equal(t, fakeStdout.String(), EXPECTED_APP_HELP_OUT)
58+
assert.NoError(t, err)
59+
assert.Equal(t, EXPECTED_APP_HELP_OUT, fakeStdout.String())
5960
}
6061

6162
func TestEntrypointNewAppWrapsCommandHelpPrinter(t *testing.T) {
@@ -64,8 +65,8 @@ func TestEntrypointNewAppWrapsCommandHelpPrinter(t *testing.T) {
6465
app.Writer = fakeStdout
6566
args := []string{"houston", "help", "exec"}
6667
err := app.Run(args)
67-
assert.Nil(t, err)
68-
assert.Equal(t, fakeStdout.String(), EXPECTED_EXEC_CMD_HELP_OUT)
68+
assert.NoError(t, err)
69+
assert.Equal(t, EXPECTED_EXEC_CMD_HELP_OUT, fakeStdout.String())
6970
}
7071

7172
func TestEntrypointNewAppHelpPrinterHonorsLineWidthVar(t *testing.T) {
@@ -75,8 +76,8 @@ func TestEntrypointNewAppHelpPrinterHonorsLineWidthVar(t *testing.T) {
7576
app.Writer = fakeStdout
7677
args := []string{"houston", "help"}
7778
err := app.Run(args)
78-
assert.Nil(t, err)
79-
assert.Equal(t, fakeStdout.String(), EXPECTED_APP_HELP_OUT_120_LINES)
79+
assert.NoError(t, err)
80+
assert.Equal(t, EXPECTED_APP_HELP_OUT_120_LINES, fakeStdout.String())
8081
}
8182

8283
func TestEntrypointNewAppCommandHelpPrinterHonorsLineWidthVar(t *testing.T) {
@@ -86,8 +87,8 @@ func TestEntrypointNewAppCommandHelpPrinterHonorsLineWidthVar(t *testing.T) {
8687
app.Writer = fakeStdout
8788
args := []string{"houston", "help", "exec"}
8889
err := app.Run(args)
89-
assert.Nil(t, err)
90-
assert.Equal(t, fakeStdout.String(), EXPECTED_EXEC_CMD_HELP_OUT_120_LINES)
90+
assert.NoError(t, err)
91+
assert.Equal(t, EXPECTED_EXEC_CMD_HELP_OUT_120_LINES, fakeStdout.String())
9192
}
9293

9394
func noop(c *cli.Context) error { return nil }
@@ -100,9 +101,10 @@ func createSampleApp() *cli.App {
100101
app.Description = `A CLI tool for interacting with Gruntwork Houston that you can use to authenticate to AWS on the CLI and to SSH to your EC2 Instances.`
101102

102103
configFlag := cli.StringFlag{
103-
Name: "config, c",
104-
Value: "~/.houston/houston.yml",
105-
Usage: "The configuration file for houston",
104+
Name: "config",
105+
Aliases: []string{"c"},
106+
Value: "~/.houston/houston.yml",
107+
Usage: "The configuration file for houston",
106108
}
107109

108110
portFlag := cli.IntFlag{
@@ -111,7 +113,7 @@ func createSampleApp() *cli.App {
111113
Usage: "The TCP port the http server is running on",
112114
}
113115

114-
app.Commands = []cli.Command{
116+
app.Commands = []*cli.Command{
115117
{
116118
Name: "exec",
117119
Usage: "Execute a command with temporary AWS credentials obtained by logging into Gruntwork Houston",
@@ -130,7 +132,7 @@ Examples:
130132
houston exec prod -- terraform apply
131133
houston exec stage -- packer build server.json`,
132134
Action: noop,
133-
Flags: []cli.Flag{configFlag, portFlag},
135+
Flags: []cli.Flag{&configFlag, &portFlag},
134136
},
135137
{
136138
Name: "ssh",
@@ -155,15 +157,15 @@ Examples:
155157
156158
houston ssh grunt@11.22.33.44`,
157159
Action: noop,
158-
Flags: []cli.Flag{configFlag, portFlag},
160+
Flags: []cli.Flag{&configFlag, &portFlag},
159161
},
160162
{
161163
Name: "configure",
162164
Usage: "Configure houston CLI options.",
163165
UsageText: "houston configure [options]",
164166
Description: `The configure command can be used to setup or update the houston configuration file. When you run this command with no arguments, it will prompt you with the minimum required options for getting the CLI up and running. The prompt will include the current value as a default if the configuration file exists.`,
165167
Action: noop,
166-
Flags: []cli.Flag{configFlag},
168+
Flags: []cli.Flag{&configFlag},
167169
},
168170
}
169171
return app

entrypoint/help_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var HelpTextLineWidth = 80
1818
// - Headers are title cased as opposed to all caps
1919
// - NAME, VERSION, AUTHOR, COPYRIGHT, and GLOBAL OPTIONS sections are removed
2020
// - Global options are displayed by name in the usage text
21-
const CLI_APP_HELP_TEMPLATE = `Usage: {{if .UsageText }}{{.UsageText}}{{else}}{{.HelpName}} {{range $index, $option := .VisibleFlags}}[{{$option.GetName | PrefixedFirstFlagName}}] {{end}}{{if .Commands}}command [options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[args]{{end}}{{end}}{{if .Description}}
21+
const CLI_APP_HELP_TEMPLATE = `Usage: {{if .UsageText }}{{.UsageText}}{{else}}{{.HelpName}} {{range $index, $option := .VisibleFlags}}[{{$option.Name | PrefixedFirstFlagName}}] {{end}}{{if .Commands}}command [options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[args]{{end}}{{end}}{{if .Description}}
2222
2323
{{.Description}}{{end}}{{if .Commands}}
2424

errors/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
goerrors "github.com/go-errors/errors"
7-
"github.com/urfave/cli"
7+
"github.com/urfave/cli/v2"
88
)
99

1010
// If this error is returned, the program should exit with the given exit code.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/pquerna/otp v1.2.1-0.20191009055518-468c2dd2b58d // indirect
2929
github.com/sirupsen/logrus v1.6.0
3030
github.com/stretchr/testify v1.6.1
31-
github.com/urfave/cli v1.22.4
31+
github.com/urfave/cli/v2 v2.3.0
3232
github.com/zclconf/go-cty v1.8.1 // indirect
3333
golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670
3434
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxK
66
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
77
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
88
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
9-
cloud.google.com/go v0.51.0 h1:PvKAVQWCtlGUSlZkGW3QLelKaWq7KYv/MW1EboG8bfM=
109
cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw=
1110
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
1211
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
@@ -472,9 +471,10 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
472471
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
473472
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
474473
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
474+
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
475475
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
476-
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
477-
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
476+
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
477+
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
478478
github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238/go.mod h1:JwQJCMWpUDqjZrB5jpw0f5VbN7U95zxFy1ZDpoEarGo=
479479
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
480480
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
@@ -821,6 +821,7 @@ gopkg.in/warnings.v0 v0.1.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN
821821
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
822822
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
823823
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
824+
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
824825
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
825826
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
826827
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=

0 commit comments

Comments
 (0)