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
b987c99e
Commit
b987c99e
authored
Nov 04, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(init) extract dspath
parent
3c865750
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
cmd/ipfs2/init.go
cmd/ipfs2/init.go
+14
-11
No files found.
cmd/ipfs2/init.go
View file @
b987c99e
...
...
@@ -27,7 +27,15 @@ var initCmd = &cmds.Command{
new keypair.
`
,
Run
:
func
(
res
cmds
.
Response
,
req
cmds
.
Request
)
{
err
:=
foo
(
res
,
req
)
arg
,
found
:=
req
.
Option
(
"d"
)
dspath
,
ok
:=
arg
.
(
string
)
// TODO param
if
found
&&
!
ok
{
res
.
SetError
(
errors
.
New
(
"failed to parse datastore flag"
),
cmds
.
ErrNormal
)
return
}
err
:=
foo
(
res
,
req
,
dspath
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
...
...
@@ -35,7 +43,7 @@ var initCmd = &cmds.Command{
},
}
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
)
error
{
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
,
dspath
string
)
error
{
ctx
:=
req
.
Context
()
u
.
POut
(
"initializing ipfs node at %s
\n
"
,
ctx
.
ConfigRoot
)
...
...
@@ -44,17 +52,12 @@ func foo(res cmds.Response, req cmds.Request) error {
return
errors
.
New
(
"Couldn't get home directory path"
)
}
arg
,
found
:=
req
.
Option
(
"d"
)
dspath
,
ok
:=
arg
.
(
string
)
if
found
&&
!
ok
{
return
errors
.
New
(
"failed to parse datastore flag"
)
}
arg
,
found
=
req
.
Option
(
"f"
)
force
,
ok
:=
arg
.
(
bool
)
arg
,
found
:=
req
.
Option
(
"f"
)
force
,
ok
:=
arg
.
(
bool
)
// TODO param
if
found
&&
!
ok
{
return
errors
.
New
(
"failed to parse force flag"
)
}
fi
,
err
:=
os
.
Lstat
(
filename
)
if
fi
!=
nil
||
(
err
!=
nil
&&
!
os
.
IsNotExist
(
err
))
{
if
!
force
{
...
...
@@ -101,7 +104,7 @@ func foo(res cmds.Response, req cmds.Request) error {
}
arg
,
found
=
req
.
Option
(
"b"
)
nbits
,
ok
:=
arg
.
(
int
)
nbits
,
ok
:=
arg
.
(
int
)
// TODO param
if
found
&&
!
ok
{
return
errors
.
New
(
"failed to get bits flag"
)
}
else
if
!
found
{
...
...
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