Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
e92c4445
Commit
e92c4445
authored
Dec 04, 2016
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cmd: clean up default logic of --progress option
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
0b8e0327
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
core/commands/add.go
core/commands/add.go
+11
-21
No files found.
core/commands/add.go
View file @
e92c4445
...
...
@@ -80,11 +80,14 @@ You can now refer to the added file in a gateway, like so:
cmds
.
BoolOption
(
rawLeavesOptionName
,
"Use raw blocks for leaf nodes. (experimental)"
),
},
PreRun
:
func
(
req
cmds
.
Request
)
error
{
if
quiet
,
_
,
_
:=
req
.
Option
(
quietOptionName
)
.
Bool
();
quiet
{
quiet
,
_
,
_
:=
req
.
Option
(
quietOptionName
)
.
Bool
()
silent
,
_
,
_
:=
req
.
Option
(
silentOptionName
)
.
Bool
()
if
quiet
||
silent
{
return
nil
}
// ipfs cli progress bar defaults to true
// ipfs cli progress bar defaults to true
unless quiet or silent is used
_
,
found
,
_
:=
req
.
Option
(
progressOptionName
)
.
Bool
()
if
!
found
{
req
.
SetOption
(
progressOptionName
,
true
)
...
...
@@ -245,27 +248,14 @@ You can now refer to the added file in a gateway, like so:
return
}
progress
,
prgFound
,
err
:=
req
.
Option
(
progressOptionName
)
.
Bool
()
progress
,
_
,
err
:=
req
.
Option
(
progressOptionName
)
.
Bool
()
if
err
!=
nil
{
res
.
SetError
(
u
.
ErrCast
(),
cmds
.
ErrNormal
)
return
}
silent
,
_
,
err
:=
req
.
Option
(
silentOptionName
)
.
Bool
()
if
err
!=
nil
{
res
.
SetError
(
u
.
ErrCast
(),
cmds
.
ErrNormal
)
return
}
var
showProgressBar
bool
if
prgFound
{
showProgressBar
=
progress
}
else
if
!
quiet
&&
!
silent
{
showProgressBar
=
true
}
var
bar
*
pb
.
ProgressBar
if
showP
rogress
Bar
{
if
p
rogress
{
bar
=
pb
.
New64
(
0
)
.
SetUnits
(
pb
.
U_BYTES
)
bar
.
ManualUpdate
=
true
bar
.
ShowTimeLeft
=
false
...
...
@@ -292,7 +282,7 @@ You can now refer to the added file in a gateway, like so:
}
output
:=
out
.
(
*
coreunix
.
AddedObject
)
if
len
(
output
.
Hash
)
>
0
{
if
showP
rogress
Bar
{
if
p
rogress
{
// clear progress bar line before we print "added x" output
fmt
.
Fprintf
(
res
.
Stderr
(),
"
\0
33[2K
\r
"
)
}
...
...
@@ -305,7 +295,7 @@ You can now refer to the added file in a gateway, like so:
}
else
{
log
.
Debugf
(
"add progress: %v %v
\n
"
,
output
.
Name
,
output
.
Bytes
)
if
!
showP
rogress
Bar
{
if
!
p
rogress
{
continue
}
...
...
@@ -321,11 +311,11 @@ You can now refer to the added file in a gateway, like so:
totalProgress
=
bar
.
Add64
(
delta
)
}
if
showP
rogress
Bar
{
if
p
rogress
{
bar
.
Update
()
}
case
size
:=
<-
sizeChan
:
if
showP
rogress
Bar
{
if
p
rogress
{
bar
.
Total
=
size
bar
.
ShowPercent
=
true
bar
.
ShowBar
=
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment