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
fa5ca3f2
Commit
fa5ca3f2
authored
Nov 10, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ipfs2/main) output response
parent
cda68a19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+16
-5
No files found.
cmd/ipfs2/main.go
View file @
fa5ca3f2
package
main
import
(
"errors"
"fmt"
"io"
"os"
...
...
@@ -80,7 +81,11 @@ func run() error {
if
err
!=
nil
{
return
err
}
outputResponse
(
res
,
root
)
err
=
outputResponse
(
res
,
root
)
if
err
!=
nil
{
return
err
}
return
nil
}
...
...
@@ -205,10 +210,15 @@ func callCommand(req cmds.Request, root *cmds.Command) (cmds.Response, error) {
return
res
,
nil
}
func
outputResponse
(
res
cmds
.
Response
,
root
*
cmds
.
Command
)
{
func
outputResponse
(
res
cmds
.
Response
,
root
*
cmds
.
Command
)
error
{
if
res
.
Error
()
!=
nil
{
fmt
.
Printf
(
errorFormat
,
res
.
Error
()
.
Error
())
if
res
.
Error
()
.
Code
!=
cmds
.
ErrClient
{
return
res
.
Error
()
}
// if this is a client error, we try to display help text
if
res
.
Error
()
.
Code
==
cmds
.
ErrClient
{
helpText
,
err
:=
cmdsCli
.
HelpText
(
"ipfs"
,
root
,
res
.
Request
()
.
Path
())
if
err
!=
nil
{
...
...
@@ -218,16 +228,17 @@ func outputResponse(res cmds.Response, root *cmds.Command) {
}
}
exit
(
1
)
emptyErr
:=
errors
.
New
(
""
)
// already displayed error text, but want to exit(1)
return
emptyErr
}
out
,
err
:=
res
.
Reader
()
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
return
return
err
}
io
.
Copy
(
os
.
Stdout
,
out
)
return
nil
}
func
getConfigRoot
(
req
cmds
.
Request
)
(
string
,
error
)
{
...
...
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