@@ -61,11 +61,7 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
6161 `The default timeout in seconds with the HTTP request` )
6262 flags .IntVarP (& opt .MaxAttempts , "max-attempts" , "" , 10 ,
6363 `Max times to attempt to download, zero means there's no retry action'` )
64- flags .BoolVarP (& opt .NoProxy , "no-proxy" , "" , false , "Indicate no HTTP proxy taken" )
65- flags .BoolVarP (& opt .ShowProgress , "show-progress" , "" , true , "If show the progress of download" )
6664 flags .Int64VarP (& opt .ContinueAt , "continue-at" , "" , - 1 , "ContinueAt" )
67- flags .IntVarP (& opt .Thread , "thread" , "t" , viper .GetInt ("thread" ),
68- `Download file with multi-threads. It only works when its value is bigger than 1` )
6965 flags .BoolVarP (& opt .KeepPart , "keep-part" , "" , false ,
7066 "If you want to keep the part files instead of deleting them" )
7167 flags .BoolVarP (& opt .PrintSchema , "print-schema" , "" , false ,
@@ -77,10 +73,7 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
7773 flags .IntVarP (& opt .PrintVersionCount , "print-version-count" , "" , 20 ,
7874 "The number of the version list" )
7975 flags .BoolVarP (& opt .Magnet , "magnet" , "" , false , "Fetch magnet list from a website" )
80-
81- _ = cmd .RegisterFlagCompletionFunc ("proxy-github" , ArrayCompletion ("gh.api.99988866.xyz" ,
82- "ghproxy.com" , "mirror.ghproxy.com" ))
83- _ = cmd .RegisterFlagCompletionFunc ("provider" , ArrayCompletion (ProviderGitHub , ProviderGitee ))
76+ flags .StringVarP (& opt .Format , "format" , "" , "" , "Specific the file format, for instance: tar, zip, msi" )
8477 return
8578}
8679
@@ -111,6 +104,7 @@ type downloadOption struct {
111104 Force bool
112105 Mod int
113106 SkipTLS bool
107+ Format string
114108
115109 ContinueAt int64
116110
@@ -145,6 +139,10 @@ const (
145139func (o * downloadOption ) addDownloadFlags (flags * pflag.FlagSet ) {
146140 flags .IntVarP (& o .Mod , "mod" , "" , - 1 , "The file permission, -1 means using the system default" )
147141 flags .BoolVarP (& o .SkipTLS , "skip-tls" , "k" , false , "Skip the TLS" )
142+ flags .BoolVarP (& o .ShowProgress , "show-progress" , "" , true , "If show the progress of download" )
143+ flags .IntVarP (& o .Thread , "thread" , "t" , viper .GetInt ("thread" ),
144+ `Download file with multi-threads. It only works when its value is bigger than 1` )
145+ flags .BoolVarP (& o .NoProxy , "no-proxy" , "" , viper .GetBool ("no-proxy" ), "Indicate no HTTP proxy taken" )
148146}
149147
150148func (o * downloadOption ) fetch () (err error ) {
@@ -195,7 +193,11 @@ func (o *downloadOption) preRunE(cmd *cobra.Command, args []string) (err error)
195193 }
196194
197195 targetURL := args [0 ]
198- o .Package = & installer.HDConfig {}
196+ o .Package = & installer.HDConfig {
197+ FormatOverrides : installer.PackagingFormat {
198+ Format : o .Format ,
199+ },
200+ }
199201 if o .Magnet || strings .HasPrefix (targetURL , "magnet:?" ) {
200202 // download via external tool
201203 o .URL = targetURL
@@ -206,6 +208,7 @@ func (o *downloadOption) preRunE(cmd *cobra.Command, args []string) (err error)
206208 OS : o .OS ,
207209 Arch : o .Arch ,
208210 Fetch : o .Fetch ,
211+ Package : o .Package ,
209212 }
210213 if targetURL , err = ins .ProviderURLParse (targetURL , o .AcceptPreRelease ); err != nil {
211214 err = fmt .Errorf ("only http:// or https:// supported, error: %v" , err )
@@ -351,7 +354,6 @@ func (o *downloadOption) runE(cmd *cobra.Command, args []string) (err error) {
351354 }
352355 var yes bool
353356 if confirmErr := survey .AskOne (confirm , & yes ); confirmErr == nil && yes {
354- fmt .Println ("rename" )
355357 err = sysos .Rename (o .Output , suggested )
356358 }
357359 }
0 commit comments