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
968ec344
Commit
968ec344
authored
Oct 15, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Oct 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Made Parse return a Request object instead of separate values
parent
7a36278d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
commands/cli/parse.go
commands/cli/parse.go
+7
-7
No files found.
commands/cli/parse.go
View file @
968ec344
...
...
@@ -7,23 +7,23 @@ import (
"github.com/jbenet/go-ipfs/commands"
)
func
Parse
(
input
[]
string
,
root
*
commands
.
Command
)
(
[]
string
,
[]
string
,
map
[
string
]
string
,
error
)
{
func
Parse
(
input
[]
string
,
root
*
commands
.
Command
)
(
*
commands
.
Request
,
error
)
{
path
,
input
,
err
:=
parsePath
(
input
,
root
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
return
nil
,
err
}
options
,
err
:=
root
.
GetOptions
(
path
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
return
nil
,
err
}
opts
,
args
,
err
:=
parseOptions
(
input
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
return
nil
,
err
}
return
path
,
args
,
opts
,
nil
return
commands
.
NewRequest
(
path
,
opts
,
args
)
,
nil
}
// parsePath gets the command path from the command line input
...
...
@@ -49,8 +49,8 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
// parseOptions parses the raw string values of the given options
// returns the parsed options as strings, along with the CLI args
func
parseOptions
(
input
[]
string
,
options
map
[
string
]
commands
.
Option
)
(
map
[
string
]
string
,
[]
string
,
error
)
{
opts
:=
make
(
map
[
string
]
string
)
func
parseOptions
(
input
[]
string
,
options
map
[
string
]
commands
.
Option
)
(
map
[
string
]
interface
{}
,
[]
string
,
error
)
{
opts
:=
make
(
map
[
string
]
interface
{}
)
args
:=
make
([]
string
,
0
)
// TODO: error if one option is defined multiple times
...
...
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