diff --git a/cmd/git-prep-directory/main.go b/cmd/git-prep-directory/main.go index 2e373f0..86e5149 100644 --- a/cmd/git-prep-directory/main.go +++ b/cmd/git-prep-directory/main.go @@ -8,7 +8,7 @@ import ( "github.com/sensiblecodeio/git-prep-directory" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) // CloneTimeout specifies the duration allowed for each individual `git clone` @@ -23,51 +23,53 @@ func init() { func main() { app := cli.NewApp() app.Name = "git-prep-directory" - app.Version = "0.5.0" + app.Version = "0.6.0" app.Usage = "Build tools friendly way of repeatedly cloning a git\n" + " repository using a submodule cache and setting file timestamps to commit times." app.Action = actionMain app.Flags = []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "url, u", Usage: "URL to clone", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "ref, r", Usage: "ref to checkout", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "destination, d", Usage: "destination dir", Value: "./src", }, - cli.DurationFlag{ - Name: "timeout, t", - Usage: "clone timeout", - Value: CloneTimeout, - EnvVar: "GIT_PREP_DIR_TIMEOUT", + &cli.DurationFlag{ + Name: "timeout, t", + Usage: "clone timeout", + Value: CloneTimeout, + EnvVars: []string{"GIT_PREP_DIR_TIMEOUT"}, }, } app.RunAndExitOnError() } -func actionMain(c *cli.Context) { - if !c.GlobalIsSet("url") || !c.GlobalIsSet("ref") { +func actionMain(c *cli.Context) error { + if !c.IsSet("url") || !c.IsSet("ref") { log.Fatalln("Error: --url and --ref required") } where, err := git.PrepBuildDirectory( - c.GlobalString("destination"), - c.GlobalString("url"), - c.GlobalString("ref"), - c.GlobalDuration("timeout"), + c.String("destination"), + c.String("url"), + c.String("ref"), + c.Duration("timeout"), os.Stderr) if err != nil { log.Fatalln("Error:", err) } log.Printf("Checked out %v at %v", where.Name, where.Dir) fmt.Println(where.Dir) + + return nil } diff --git a/go.mod b/go.mod index 56886c1..89070be 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,13 @@ module github.com/sensiblecodeio/git-prep-directory go 1.23.4 require ( - github.com/urfave/cli v1.22.7 + github.com/urfave/cli/v2 v2.27.5 github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec golang.org/x/sys v0.29.0 ) require ( - github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect ) diff --git a/go.sum b/go.sum index d1b9fe8..04006b3 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,12 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/urfave/cli v1.22.7 h1:aXiFAgRugfJ27UFDsGJ9DB2FvTC73hlVXFSqq5bo9eU= -github.com/urfave/cli v1.22.7/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= +github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec h1:DGmKwyZwEB8dI7tbLt/I/gQuP559o/0FrAkHKlQM/Ks= github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec/go.mod h1:owBmyHYMLkxyrugmfwE/DLJyW8Ro9mkphwuVErQ0iUw= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=