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
201ad30a
Commit
201ad30a
authored
Oct 23, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ipfs: Run CLI-specific subcommands locally in CLI entry point
parent
ccfb10dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
10 deletions
+40
-10
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+40
-10
No files found.
cmd/ipfs/ipfs.go
View file @
201ad30a
...
...
@@ -21,26 +21,46 @@ var log = u.Logger("cmd/ipfs")
const
API_PATH
=
"/api/v0"
func
main
()
{
req
,
err
:=
cli
.
Parse
(
os
.
Args
[
1
:
],
commands
.
Root
)
args
:=
os
.
Args
[
1
:
]
req
,
err
:=
cli
.
Parse
(
args
,
Root
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
// TODO: call command locally if option tells us to, or if command is CLI-only (e.g. ipfs init)
cmd
,
err
:
=
commands
.
Root
.
Get
(
req
.
Path
())
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
if
len
(
req
.
Path
())
==
0
{
req
,
err
=
cli
.
Parse
(
args
,
commands
.
Root
)
if
err
!
=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
}
res
,
err
:=
sendRequest
(
req
)
if
err
!=
nil
{
var
local
bool
// TODO: option to force local
var
root
*
cmds
.
Command
cmd
,
err
:=
Root
.
Get
(
req
.
Path
())
if
err
==
nil
{
local
=
true
root
=
Root
}
else
if
local
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
else
{
cmd
,
err
=
commands
.
Root
.
Get
(
req
.
Path
())
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
local
=
false
root
=
commands
.
Root
}
// TODO: get converted options so we can use them here (e.g. --debug, --config)
if
debug
,
ok
:=
req
.
Option
(
"debug"
);
ok
&&
debug
.
(
bool
)
{
u
.
Debug
=
true
...
...
@@ -57,7 +77,17 @@ func main() {
}
}
//res := commands.Root.Call(req)
var
res
cmds
.
Response
if
local
{
// TODO: spin up node
res
=
root
.
Call
(
req
)
}
else
{
res
,
err
=
sendRequest
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
}
if
res
.
Error
()
!=
nil
{
fmt
.
Println
(
res
.
Error
()
.
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