diff --git a/go.mod b/go.mod index 38c9579..d6ec39a 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module redl go 1.21.4 require ( - github.com/gek64/gek v1.1.1-0.20231213065838-ccb663823d94 + github.com/gek64/gek v1.1.2-0.20231222091541-e37b3f00c2a9 github.com/urfave/cli/v2 v2.26.0 ) require ( github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect ) diff --git a/go.sum b/go.sum index 5fcc8c8..50cefb4 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,10 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/gek64/gek v1.1.1-0.20231212171036-c563ca8bf4d5 h1:sc8IEwuuhv9ztxMvUkhbIIDxN6gEg6G7R958CKc7w+c= -github.com/gek64/gek v1.1.1-0.20231212171036-c563ca8bf4d5/go.mod h1:84OKdazk9Mi94sDNt70r7Bc1pjRm5BQtN4mPTaLZU8w= -github.com/gek64/gek v1.1.1-0.20231213065838-ccb663823d94 h1:muKRvKVnhHXB4MhGQctnDoJv1yRdp61zah/DIt5JVE8= -github.com/gek64/gek v1.1.1-0.20231213065838-ccb663823d94/go.mod h1:lMjX11RAL+bdrcYglnFoQQFsUXrgR5odUTWLZlg4Mj8= +github.com/gek64/gek v1.1.2-0.20231222091541-e37b3f00c2a9 h1:3+foBBZXBQm3ZugExmeO9EdQkn27GyP+f0Er61WxhqU= +github.com/gek64/gek v1.1.2-0.20231222091541-e37b3f00c2a9/go.mod h1:oalulJSH0OM6LRbjGwpw305/d7h9VE5P1wDbDR0KUyQ= 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/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI= github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= diff --git a/main.go b/main.go index 94dc70b..3d3f989 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "github.com/gek64/gek/gDownloader" + "github.com/gek64/gek/gToolbox" "github.com/urfave/cli/v2" "log" "os" @@ -58,28 +59,35 @@ func main() { Usage: "Release Download Tool", Version: "v2.00", Flags: flags, - Action: func(ctx *cli.Context) error { + Action: func(ctx *cli.Context) (err error) { var downloadLink string - var err error // 获取下载链接 if github_release != "" { downloadLink, err = internal.GetGithubDownloadLink(github_release, included_parts.Value(), excluded_parts.Value()) if err != nil { - log.Fatalln(err) + return err } } else if sourceforge_release != "" { downloadLink, err = internal.GetSourceForgeDownloadLink(sourceforge_release, included_parts.Value(), excluded_parts.Value()) if err != nil { - log.Fatalln(err) + return err } } // 下载 if downloadLink != "" { - err = gDownloader.Downloader(downloadLink, "", output) + err = gToolbox.CheckToolbox([]string{"curl"}) if err != nil { - log.Fatalln(err) + err := gDownloader.Download(downloadLink, output, "") + if err != nil { + return err + } + } else { + err := gDownloader.DownloadWithCurl(downloadLink, output, "") + if err != nil { + return err + } } } return nil