Skip to content

Commit d283c32

Browse files
authored
Simpify the params of hd get (#7)
* Simpify the params of hd get * Bump linuxsuren/cobra-extension from v0.0.9 to v0.0.10
1 parent c51fa51 commit d283c32

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

cmd/root.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ func NewRoot() (cmd *cobra.Command) {
3232
flags.StringVarP(&opt.Output, "output", "o", "", "Write output to <file> instead of stdout.")
3333
flags.BoolVarP(&opt.ShowProgress, "show-progress", "", true, "If show the progress of download")
3434
flags.Int64VarP(&opt.ContinueAt, "continue-at", "", -1, "ContinueAt")
35-
flags.IntVarP(&opt.Thread, "thread", "", 0, "")
35+
flags.IntVarP(&opt.Thread, "thread", "t", 0,
36+
`Download file with multi-threads. It only works when its value is bigger than 1`)
3637
flags.BoolVarP(&opt.KeepPart, "keep-part", "", false,
3738
"If you want to keep the part files instead of deleting them")
3839
flags.StringVarP(&opt.Provider, "provider", "", ProviderGitHub, "The file provider")
39-
flags.StringVarP(&opt.OS, "os", "", "", "The OS of target binary file")
40-
flags.StringVarP(&opt.Arch, "arch", "", "", "The arch of target binary file")
40+
flags.StringVarP(&opt.OS, "os", "", runtime.GOOS, "The OS of target binary file")
41+
flags.StringVarP(&opt.Arch, "arch", "", runtime.GOARCH, "The arch of target binary file")
4142

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

118-
if o.OS == "" {
119-
o.OS = runtime.GOOS
120-
}
121-
122-
if o.Arch == "" {
123-
o.Arch = runtime.GOARCH
124-
}
125-
126119
targetURL := args[0]
127120
if !strings.HasPrefix(targetURL, "http://") && !strings.HasPrefix(targetURL, "https://") {
128121
if targetURL, err = o.providerURLParse(targetURL); err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.15
55
require (
66
github.com/golang/mock v1.4.4
77
github.com/gosuri/uiprogress v0.0.1
8-
github.com/linuxsuren/cobra-extension v0.0.9
8+
github.com/linuxsuren/cobra-extension v0.0.10
99
github.com/onsi/ginkgo v1.14.2
1010
github.com/onsi/gomega v1.10.4
1111
github.com/spf13/cobra v1.1.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ github.com/linuxsuren/cobra-extension v0.0.6 h1:JlSmHjE/KCdJBZYGTjQbgvXSpziFwzpI
162162
github.com/linuxsuren/cobra-extension v0.0.6/go.mod h1:qcEJv7BbL0UpK6MbrTESP/nKf1+z1wQdMAnE1NBl3QQ=
163163
github.com/linuxsuren/cobra-extension v0.0.9 h1:VojTxx/eROco/fCatmz81L48gyy0AEPu1Tz6oFIaLak=
164164
github.com/linuxsuren/cobra-extension v0.0.9/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do=
165+
github.com/linuxsuren/cobra-extension v0.0.10 h1:ciZDb2Bp/aAFqr4YoeVuH2uyBaBFfO6pwz1WBih7R4A=
166+
github.com/linuxsuren/cobra-extension v0.0.10/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do=
165167
github.com/linuxsuren/http-downloader v0.0.2-0.20201207132639-19888a6beaec/go.mod h1:zRZY9FCDBuYNDxbI2Ny5suasZsMk7J6q9ecQ3V3PIqI=
166168
github.com/linuxsuren/http-downloader v0.0.6/go.mod h1:xxgh2OE7WGL9TwDE9L8Gh7Lqq9fFPuHbh5tofUitEfE=
167169
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=

0 commit comments

Comments
 (0)