Skip to content

Commit ba9f70e

Browse files
dev: Update module github.com/urfave/cli/v2 to v3 (#105)
Co-authored-by: mm-renovate-bot[bot] <265138953+mm-renovate-bot[bot]@users.noreply.github.com> Co-authored-by: Hans Baker <hansbaker90@gmail.com>
1 parent 12e0219 commit ba9f70e

3 files changed

Lines changed: 31 additions & 31 deletions

File tree

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ require (
88
github.com/google/go-github/v63 v63.0.0
99
github.com/pelletier/go-toml/v2 v2.2.4
1010
github.com/sourcegraph/go-diff v0.7.0
11-
github.com/urfave/cli/v2 v2.27.7
11+
github.com/urfave/cli/v3 v3.7.0
1212
)
1313

1414
require (
15-
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
1615
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
1716
github.com/google/go-querystring v1.1.0 // indirect
18-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
19-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
2017
golang.org/x/sync v0.12.0 // indirect
2118
)

go.sum

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6
22
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
33
github.com/boyter/gocodewalker v1.5.1 h1:0YeK2QAkd+ymW5MsagMZapIXD3v9/vrZl0HkFSLpKsw=
44
github.com/boyter/gocodewalker v1.5.1/go.mod h1:9k+yM6+fIx61F0xI9ChXEGE5DYoLhggw8AxSOtW+kKo=
5-
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
6-
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
75
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
86
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
7+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1010
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1111
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -15,16 +15,18 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
1515
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
1616
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
1717
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
18-
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
19-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
18+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
19+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2020
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
2121
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
2222
github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0=
2323
github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
24-
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
25-
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
26-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
27-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
24+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
25+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
26+
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
27+
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
2828
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
2929
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
3030
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
31+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
32+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

tools/cli/main.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"bytes"
5+
"context"
56
"encoding/json"
67
"fmt"
78
"io"
@@ -13,7 +14,7 @@ import (
1314
"github.com/boyter/gocodewalker"
1415
"github.com/multimediallc/codeowners-plus/pkg/codeowners"
1516
f "github.com/multimediallc/codeowners-plus/pkg/functional"
16-
"github.com/urfave/cli/v2"
17+
"github.com/urfave/cli/v3"
1718
)
1819

1920
func stripRoot(root string, path string) string {
@@ -23,10 +24,10 @@ func stripRoot(root string, path string) string {
2324
return strings.TrimPrefix(path, root+"/")
2425
}
2526

26-
func getTargets(cCtx *cli.Context) ([]string, error) {
27+
func getTargets(cmd *cli.Command) ([]string, error) {
2728
var targets []string
28-
if cCtx.NArg() > 0 {
29-
targets = cCtx.Args().Slice()
29+
if cmd.NArg() > 0 {
30+
targets = cmd.Args().Slice()
3031
} else if isStdinPiped() {
3132
var err error
3233
targets, err = scanStdin()
@@ -44,10 +45,10 @@ func main() {
4445
Aliases: []string{"v"},
4546
Usage: "Print version",
4647
}
47-
cli.VersionPrinter = func(cCtx *cli.Context) {
48-
fmt.Println(cCtx.App.Version)
48+
cli.VersionPrinter = func(cmd *cli.Command) {
49+
fmt.Println(cmd.Root().Version)
4950
}
50-
app := &cli.App{
51+
app := &cli.Command{
5152
Name: "codeowners-cli",
5253
Usage: "CLI tool for working with .codeowners files",
5354
Version: "v1.9.1.dev",
@@ -86,17 +87,17 @@ func main() {
8687
Usage: "Output format. Allowed values are: default, one-line, and json",
8788
},
8889
},
89-
Action: func(cCtx *cli.Context) error {
90-
targets, err := getTargets(cCtx)
90+
Action: func(ctx context.Context, cmd *cli.Command) error {
91+
targets, err := getTargets(cmd)
9192
if err != nil {
9293
return err
9394
}
9495

95-
format, err := validateFormat(cCtx.String("format"))
96+
format, err := validateFormat(cmd.String("format"))
9697
if err != nil {
9798
return err
9899
}
99-
return unownedFilesWithFormat(repo, targets, cCtx.Int("depth"), cCtx.Bool("dirs_only"), format)
100+
return unownedFilesWithFormat(repo, targets, int(cmd.Int("depth")), cmd.Bool("dirs_only"), format)
100101
},
101102
},
102103
{
@@ -120,8 +121,8 @@ func main() {
120121
Usage: "Output format. Allowed values are: default, one-line, and json",
121122
},
122123
},
123-
Action: func(cCtx *cli.Context) error {
124-
targets, err := getTargets(cCtx)
124+
Action: func(ctx context.Context, cmd *cli.Command) error {
125+
targets, err := getTargets(cmd)
125126
if err != nil {
126127
return err
127128
}
@@ -130,7 +131,7 @@ func main() {
130131
return fmt.Errorf("no target files provided (either as arguments or from stdin)")
131132
}
132133

133-
format, err := validateFormat(cCtx.String("format"))
134+
format, err := validateFormat(cmd.String("format"))
134135
if err != nil {
135136
return err
136137
}
@@ -158,8 +159,8 @@ func main() {
158159
Usage: "Output format. Allowed values are: default, one-line, and json",
159160
},
160161
},
161-
Action: func(cCtx *cli.Context) error {
162-
targets, err := getTargets(cCtx)
162+
Action: func(ctx context.Context, cmd *cli.Command) error {
163+
targets, err := getTargets(cmd)
163164
if err != nil {
164165
return err
165166
}
@@ -201,8 +202,8 @@ func main() {
201202
Usage: "Map by 'file' (files to owners) or 'owner' (owners to files)",
202203
},
203204
},
204-
Action: func(cCtx *cli.Context) error {
205-
mapBy := cCtx.String("by")
205+
Action: func(ctx context.Context, cmd *cli.Command) error {
206+
mapBy := cmd.String("by")
206207
if mapBy != "file" && mapBy != "owner" {
207208
return fmt.Errorf("invalid value for --by flag: must be 'file' or 'owner'")
208209
}
@@ -212,7 +213,7 @@ func main() {
212213
},
213214
}
214215

215-
err := app.Run(os.Args)
216+
err := app.Run(context.Background(), os.Args)
216217
if err != nil {
217218
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
218219
os.Exit(1)

0 commit comments

Comments
 (0)