@@ -2,6 +2,7 @@ package main
22
33import (
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
1920func 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