Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ func NewRoot() (cmd *cobra.Command) {
flags.StringVarP(&opt.Output, "output", "o", "", "Write output to <file> instead of stdout.")
flags.BoolVarP(&opt.ShowProgress, "show-progress", "", true, "If show the progress of download")
flags.Int64VarP(&opt.ContinueAt, "continue-at", "", -1, "ContinueAt")
flags.IntVarP(&opt.Thread, "thread", "", 0, "")
flags.IntVarP(&opt.Thread, "thread", "t", 0,
`Download file with multi-threads. It only works when its value is bigger than 1`)
flags.BoolVarP(&opt.KeepPart, "keep-part", "", false,
"If you want to keep the part files instead of deleting them")
flags.StringVarP(&opt.Provider, "provider", "", ProviderGitHub, "The file provider")
flags.StringVarP(&opt.OS, "os", "", "", "The OS of target binary file")
flags.StringVarP(&opt.Arch, "arch", "", "", "The arch of target binary file")
flags.StringVarP(&opt.OS, "os", "", runtime.GOOS, "The OS of target binary file")
flags.StringVarP(&opt.Arch, "arch", "", runtime.GOARCH, "The arch of target binary file")

cmd.AddCommand(
getCmd,
Expand Down Expand Up @@ -115,14 +116,6 @@ func (o *downloadOption) preRunE(cmd *cobra.Command, args []string) (err error)
return fmt.Errorf("no URL provided")
}

if o.OS == "" {
o.OS = runtime.GOOS
}

if o.Arch == "" {
o.Arch = runtime.GOARCH
}

targetURL := args[0]
if !strings.HasPrefix(targetURL, "http://") && !strings.HasPrefix(targetURL, "https://") {
if targetURL, err = o.providerURLParse(targetURL); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/golang/mock v1.4.4
github.com/gosuri/uiprogress v0.0.1
github.com/linuxsuren/cobra-extension v0.0.9
github.com/linuxsuren/cobra-extension v0.0.10
github.com/onsi/ginkgo v1.14.2
github.com/onsi/gomega v1.10.4
github.com/spf13/cobra v1.1.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ github.com/linuxsuren/cobra-extension v0.0.6 h1:JlSmHjE/KCdJBZYGTjQbgvXSpziFwzpI
github.com/linuxsuren/cobra-extension v0.0.6/go.mod h1:qcEJv7BbL0UpK6MbrTESP/nKf1+z1wQdMAnE1NBl3QQ=
github.com/linuxsuren/cobra-extension v0.0.9 h1:VojTxx/eROco/fCatmz81L48gyy0AEPu1Tz6oFIaLak=
github.com/linuxsuren/cobra-extension v0.0.9/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do=
github.com/linuxsuren/cobra-extension v0.0.10 h1:ciZDb2Bp/aAFqr4YoeVuH2uyBaBFfO6pwz1WBih7R4A=
github.com/linuxsuren/cobra-extension v0.0.10/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do=
github.com/linuxsuren/http-downloader v0.0.2-0.20201207132639-19888a6beaec/go.mod h1:zRZY9FCDBuYNDxbI2Ny5suasZsMk7J6q9ecQ3V3PIqI=
github.com/linuxsuren/http-downloader v0.0.6/go.mod h1:xxgh2OE7WGL9TwDE9L8Gh7Lqq9fFPuHbh5tofUitEfE=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand Down