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
203a0723
Commit
203a0723
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) return errors in main
parent
f1fc26e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+13
-12
No files found.
cmd/ipfs2/main.go
View file @
203a0723
...
...
@@ -35,7 +35,11 @@ func main() {
handleInterrupt
()
args
:=
os
.
Args
[
1
:
]
req
,
root
:=
createRequest
(
args
)
req
,
root
,
err
:=
createRequest
(
args
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
exit
(
1
)
}
handleOptions
(
req
,
root
)
// if debugging, setup profiling.
...
...
@@ -56,7 +60,7 @@ func main() {
exit
(
0
)
}
func
createRequest
(
args
[]
string
)
(
cmds
.
Request
,
*
cmds
.
Command
)
{
func
createRequest
(
args
[]
string
)
(
cmds
.
Request
,
*
cmds
.
Command
,
error
)
{
req
,
root
,
cmd
,
path
,
err
:=
cmdsCli
.
Parse
(
args
,
Root
,
commands
.
Root
)
// handle parse error (which means the commandline input was wrong,
...
...
@@ -80,27 +84,24 @@ func createRequest(args []string) (cmds.Request, *cmds.Command) {
}
// generate the help text for the command the user was trying to call (or root)
helpText
,
e
rr
:=
cmdsCli
.
HelpText
(
"ipfs"
,
root
,
path
)
if
e
rr
!=
nil
{
fmt
.
Println
(
e
rr
)
helpText
,
htE
rr
:=
cmdsCli
.
HelpText
(
"ipfs"
,
root
,
path
)
if
htE
rr
!=
nil
{
fmt
.
Println
(
htE
rr
)
}
else
{
fmt
.
Println
(
helpText
)
}
exit
(
1
)
return
nil
,
nil
,
err
}
configPath
,
err
:=
getConfigRoot
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
exit
(
1
)
return
nil
,
nil
,
err
}
conf
,
err
:=
getConfig
(
configPath
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
exit
(
1
)
return
nil
,
nil
,
err
}
ctx
:=
req
.
Context
()
ctx
.
ConfigRoot
=
configPath
ctx
.
Config
=
conf
...
...
@@ -113,7 +114,7 @@ func createRequest(args []string) (cmds.Request, *cmds.Command) {
}
}
return
req
,
root
return
req
,
root
,
nil
}
func
handleOptions
(
req
cmds
.
Request
,
root
*
cmds
.
Command
)
{
...
...
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