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
630b88d2
Commit
630b88d2
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 force flag
parent
b987c99e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
cmd/ipfs2/init.go
cmd/ipfs2/init.go
+10
-9
No files found.
cmd/ipfs2/init.go
View file @
630b88d2
...
...
@@ -29,13 +29,20 @@ var initCmd = &cmds.Command{
Run
:
func
(
res
cmds
.
Response
,
req
cmds
.
Request
)
{
arg
,
found
:=
req
.
Option
(
"d"
)
dspath
,
ok
:=
arg
.
(
string
)
// TODO param
dspath
,
ok
:=
arg
.
(
string
)
if
found
&&
!
ok
{
res
.
SetError
(
errors
.
New
(
"failed to parse datastore flag"
),
cmds
.
ErrNormal
)
return
}
err
:=
foo
(
res
,
req
,
dspath
)
arg
,
found
=
req
.
Option
(
"f"
)
force
,
ok
:=
arg
.
(
bool
)
// TODO param
if
found
&&
!
ok
{
res
.
SetError
(
errors
.
New
(
"failed to parse force flag"
),
cmds
.
ErrNormal
)
return
}
err
:=
foo
(
res
,
req
,
dspath
,
force
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
...
...
@@ -43,7 +50,7 @@ var initCmd = &cmds.Command{
},
}
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
,
dspath
string
)
error
{
func
foo
(
res
cmds
.
Response
,
req
cmds
.
Request
,
dspath
string
,
force
bool
)
error
{
ctx
:=
req
.
Context
()
u
.
POut
(
"initializing ipfs node at %s
\n
"
,
ctx
.
ConfigRoot
)
...
...
@@ -52,12 +59,6 @@ func foo(res cmds.Response, req cmds.Request, dspath string) error {
return
errors
.
New
(
"Couldn't get home directory path"
)
}
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
{
...
...
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