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
d87aad1e
Commit
d87aad1e
authored
10 years ago
by
Matt Bell
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ipfs: Do command option conversion in CLI entry point
parent
b4fc0dba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
+30
-23
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+30
-23
No files found.
cmd/ipfs/ipfs.go
View file @
d87aad1e
...
...
@@ -18,46 +18,37 @@ var log = u.Logger("cmd/ipfs")
func
main
()
{
args
:=
os
.
Args
[
1
:
]
root
:=
Root
req
,
err
:=
cmdsCli
.
Parse
(
args
,
R
oot
)
req
,
err
:=
cmdsCli
.
Parse
(
args
,
r
oot
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
// if the CLI-specific root doesn't contain the command, use the general root
if
len
(
req
.
Path
())
==
0
{
req
,
err
=
cmdsCli
.
Parse
(
args
,
commands
.
Root
)
root
=
commands
.
Root
req
,
err
=
cmdsCli
.
Parse
(
args
,
root
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
}
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
{
cmd
,
err
:=
root
.
Get
(
req
.
Path
())
if
err
!=
nil
{
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)
options
,
err
:=
getOptions
(
req
,
root
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
if
debug
,
ok
:=
req
.
O
ption
(
"debug"
)
;
ok
&&
debug
.
(
bool
)
{
if
debug
,
ok
:=
o
ption
s
[
"debug"
]
;
ok
&&
debug
.
(
bool
)
{
u
.
Debug
=
true
// if debugging, setup profiling.
...
...
@@ -74,7 +65,7 @@ func main() {
}
var
res
cmds
.
Response
if
local
{
if
root
==
Root
{
// TODO: spin up node
res
=
root
.
Call
(
req
)
}
else
{
...
...
@@ -101,3 +92,19 @@ func main() {
fmt
.
Println
(
err
.
Error
())
}
}
func
getOptions
(
req
cmds
.
Request
,
root
*
cmds
.
Command
)
(
map
[
string
]
interface
{},
error
)
{
tempReq
:=
cmds
.
NewRequest
(
req
.
Path
(),
req
.
Options
(),
nil
,
nil
)
options
,
err
:=
root
.
GetOptions
(
tempReq
.
Path
())
if
err
!=
nil
{
return
nil
,
err
}
err
=
tempReq
.
ConvertOptions
(
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
tempReq
.
Options
(),
nil
}
This diff is collapsed.
Click to expand it.
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