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
818d3af8
Commit
818d3af8
authored
Jul 24, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear progress bar on `ipfs cat` exit
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
633b66d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
core/commands/add.go
core/commands/add.go
+1
-2
core/commands/cat.go
core/commands/cat.go
+15
-1
No files found.
core/commands/add.go
View file @
818d3af8
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"io"
"path"
"strings"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
...
...
@@ -208,7 +207,7 @@ remains to be implemented.
if
len
(
output
.
Hash
)
>
0
{
if
showProgressBar
{
// clear progress bar line before we print "added x" output
fmt
.
Fprintf
(
res
.
Stderr
(),
"
\
r
%s
\r
"
,
strings
.
Repeat
(
" "
,
terminalWidth
)
)
fmt
.
Fprintf
(
res
.
Stderr
(),
"
\
0
33[2K
\r
"
)
}
if
quiet
{
fmt
.
Fprintf
(
res
.
Stdout
(),
"%s
\n
"
,
output
.
Hash
)
...
...
core/commands/cat.go
View file @
818d3af8
package
commands
import
(
"fmt"
"io"
cmds
"github.com/ipfs/go-ipfs/commands"
...
...
@@ -14,6 +15,11 @@ import (
const
progressBarMinSize
=
1024
*
1024
*
8
// show progress bar for outputs > 8MiB
type
clearlineReader
struct
{
io
.
Reader
out
io
.
Writer
}
var
CatCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Show IPFS object data"
,
...
...
@@ -54,7 +60,7 @@ it contains.
bar
.
Start
()
reader
:=
bar
.
NewProxyReader
(
res
.
Output
()
.
(
io
.
Reader
))
res
.
SetOutput
(
reader
)
res
.
SetOutput
(
&
clearlineReader
{
reader
,
res
.
Stderr
()}
)
},
}
...
...
@@ -76,3 +82,11 @@ func cat(ctx context.Context, node *core.IpfsNode, paths []string) ([]io.Reader,
}
return
readers
,
length
,
nil
}
func
(
r
*
clearlineReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
n
,
err
=
r
.
Reader
.
Read
(
p
)
if
err
==
io
.
EOF
{
fmt
.
Fprintf
(
r
.
out
,
"
\0
33[2K
\r
"
)
// clear progress bar line on EOF
}
return
}
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