@@ -80,11 +80,14 @@ You can now refer to the added file in a gateway, like so:
80
80
cmds .BoolOption (rawLeavesOptionName , "Use raw blocks for leaf nodes. (experimental)" ),
81
81
},
82
82
PreRun : func (req cmds.Request ) error {
83
- if quiet , _ , _ := req .Option (quietOptionName ).Bool (); quiet {
83
+ quiet , _ , _ := req .Option (quietOptionName ).Bool ()
84
+ silent , _ , _ := req .Option (silentOptionName ).Bool ()
85
+
86
+ if quiet || silent {
84
87
return nil
85
88
}
86
89
87
- // ipfs cli progress bar defaults to true
90
+ // ipfs cli progress bar defaults to true unless quiet or silent is used
88
91
_ , found , _ := req .Option (progressOptionName ).Bool ()
89
92
if ! found {
90
93
req .SetOption (progressOptionName , true )
@@ -245,27 +248,14 @@ You can now refer to the added file in a gateway, like so:
245
248
return
246
249
}
247
250
248
- progress , prgFound , err := req .Option (progressOptionName ).Bool ()
251
+ progress , _ , err := req .Option (progressOptionName ).Bool ()
249
252
if err != nil {
250
253
res .SetError (u .ErrCast (), cmds .ErrNormal )
251
254
return
252
255
}
253
256
254
- silent , _ , err := req .Option (silentOptionName ).Bool ()
255
- if err != nil {
256
- res .SetError (u .ErrCast (), cmds .ErrNormal )
257
- return
258
- }
259
-
260
- var showProgressBar bool
261
- if prgFound {
262
- showProgressBar = progress
263
- } else if ! quiet && ! silent {
264
- showProgressBar = true
265
- }
266
-
267
257
var bar * pb.ProgressBar
268
- if showProgressBar {
258
+ if progress {
269
259
bar = pb .New64 (0 ).SetUnits (pb .U_BYTES )
270
260
bar .ManualUpdate = true
271
261
bar .ShowTimeLeft = false
@@ -292,7 +282,7 @@ You can now refer to the added file in a gateway, like so:
292
282
}
293
283
output := out .(* coreunix.AddedObject )
294
284
if len (output .Hash ) > 0 {
295
- if showProgressBar {
285
+ if progress {
296
286
// clear progress bar line before we print "added x" output
297
287
fmt .Fprintf (res .Stderr (), "\033 [2K\r " )
298
288
}
@@ -305,7 +295,7 @@ You can now refer to the added file in a gateway, like so:
305
295
} else {
306
296
log .Debugf ("add progress: %v %v\n " , output .Name , output .Bytes )
307
297
308
- if ! showProgressBar {
298
+ if ! progress {
309
299
continue
310
300
}
311
301
@@ -321,11 +311,11 @@ You can now refer to the added file in a gateway, like so:
321
311
totalProgress = bar .Add64 (delta )
322
312
}
323
313
324
- if showProgressBar {
314
+ if progress {
325
315
bar .Update ()
326
316
}
327
317
case size := <- sizeChan :
328
- if showProgressBar {
318
+ if progress {
329
319
bar .Total = size
330
320
bar .ShowPercent = true
331
321
bar .ShowBar = true
0 commit comments