@@ -49,14 +49,13 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
49
49
flags := cmd .Flags ()
50
50
opt .addFlags (flags )
51
51
opt .addPlatformFlags (flags )
52
+ opt .addDownloadFlags (flags )
52
53
flags .StringVarP (& opt .Output , "output" , "o" , "" , "Write output to <file> instead of stdout." )
53
54
flags .BoolVarP (& opt .AcceptPreRelease , "accept-preRelease" , "" , false ,
54
55
"If you accept preRelease as the binary asset from GitHub" )
55
56
flags .BoolVarP (& opt .AcceptPreRelease , "pre" , "" , false ,
56
57
"Same with option --accept-preRelease" )
57
58
flags .BoolVarP (& opt .Force , "force" , "f" , false , "Overwrite the exist file if this is true" )
58
- flags .IntVarP (& opt .Mod , "mod" , "" , - 1 , "The file permission, -1 means using the system default" )
59
- flags .BoolVarP (& opt .SkipTLS , "skip-tls" , "k" , false , "Skip the TLS" )
60
59
61
60
flags .DurationVarP (& opt .Timeout , "timeout" , "" , 15 * time .Minute ,
62
61
`The default timeout in seconds with the HTTP request` )
@@ -143,6 +142,11 @@ const (
143
142
ProviderGitee = "gitee"
144
143
)
145
144
145
+ func (o * downloadOption ) addDownloadFlags (flags * pflag.FlagSet ) {
146
+ flags .IntVarP (& o .Mod , "mod" , "" , - 1 , "The file permission, -1 means using the system default" )
147
+ flags .BoolVarP (& o .SkipTLS , "skip-tls" , "k" , false , "Skip the TLS" )
148
+ }
149
+
146
150
func (o * downloadOption ) fetch () (err error ) {
147
151
if ! o .Fetch {
148
152
o .wait .Add (1 )
@@ -331,7 +335,10 @@ func (o *downloadOption) runE(cmd *cobra.Command, args []string) (err error) {
331
335
332
336
// set file permission
333
337
if o .Mod != - 1 {
334
- err = sysos .Chmod (o .Output , fs .FileMode (o .Mod ))
338
+ logger .Printf ("Setting file permission to %d" , o .Mod )
339
+ if err = sysos .Chmod (o .Output , fs .FileMode (o .Mod )); err != nil {
340
+ return
341
+ }
335
342
}
336
343
337
344
if err == nil {
0 commit comments