Skip to content

Commit 54dabe6

Browse files
alexbmoffatt
andauthored
Update build-lambda-zip to use urfave/cli/v2 (#266)
Co-authored-by: Bryan Moffatt <[email protected]>
1 parent 17040d2 commit 54dabe6

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

cmd/build-lambda-zip/main.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ import (
88
"os"
99
"path/filepath"
1010

11-
"github.com/urfave/cli"
11+
"github.com/urfave/cli/v2"
1212
)
1313

1414
func main() {
15-
app := cli.NewApp()
16-
app.Name = "build-lambda-zip"
17-
app.Usage = "Put an executable and supplemental files into a zip file that works with AWS Lambda."
18-
app.Flags = []cli.Flag{
19-
&cli.StringFlag{
20-
Name: "output, o",
21-
Value: "",
22-
Usage: "output file path for the zip. Defaults to the first input file name.",
15+
app := &cli.App{
16+
Name: "build-lambda-zip",
17+
Usage: "Put an executable and supplemental files into a zip file that works with AWS Lambda.",
18+
Flags: []cli.Flag{
19+
&cli.StringFlag{
20+
Name: "output, o",
21+
Value: "",
22+
Usage: "output file path for the zip. Defaults to the first input file name.",
23+
},
2324
},
24-
}
25-
26-
app.Action = func(c *cli.Context) error {
27-
if !c.Args().Present() {
28-
return errors.New("no input provided")
29-
}
25+
Action: func(c *cli.Context) error {
26+
if !c.Args().Present() {
27+
return errors.New("no input provided")
28+
}
3029

31-
inputExe := c.Args().First()
32-
outputZip := c.String("output")
33-
if outputZip == "" {
34-
outputZip = fmt.Sprintf("%s.zip", filepath.Base(inputExe))
35-
}
30+
inputExe := c.Args().First()
31+
outputZip := c.String("output")
32+
if outputZip == "" {
33+
outputZip = fmt.Sprintf("%s.zip", filepath.Base(inputExe))
34+
}
3635

37-
if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
38-
return fmt.Errorf("failed to compress file: %v", err)
39-
}
40-
return nil
36+
if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
37+
return fmt.Errorf("failed to compress file: %v", err)
38+
}
39+
return nil
40+
},
4141
}
4242

4343
if err := app.Run(os.Args); err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go 1.12
44

55
require (
66
github.com/stretchr/testify v1.4.0
7-
github.com/urfave/cli v1.22.1
7+
github.com/urfave/cli/v2 v2.1.1
88
)

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
1212
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1313
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
1414
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
15-
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
16-
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
15+
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
16+
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1718
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1819
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
1920
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)