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-unixfs
Commits
4986600e
Commit
4986600e
authored
Oct 20, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parsePath no err
parent
92528ba7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
11 deletions
+4
-11
commands/cli/parse.go
commands/cli/parse.go
+3
-7
commands/cli/parse_test.go
commands/cli/parse_test.go
+1
-4
No files found.
commands/cli/parse.go
View file @
4986600e
...
...
@@ -10,11 +10,7 @@ import (
// Parse parses the input commandline string (cmd, flags, and args).
// returns the corresponding command Request object.
func
Parse
(
input
[]
string
,
root
*
commands
.
Command
)
(
*
commands
.
Request
,
error
)
{
path
,
input
,
err
:=
parsePath
(
input
,
root
)
if
err
!=
nil
{
return
nil
,
err
}
path
,
input
:=
parsePath
(
input
,
root
)
opts
,
args
,
err
:=
parseOptions
(
input
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -24,7 +20,7 @@ func Parse(input []string, root *commands.Command) (*commands.Request, error) {
}
// parsePath gets the command path from the command line input
func
parsePath
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
,
error
)
{
func
parsePath
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
)
{
cmd
:=
root
i
:=
0
...
...
@@ -41,7 +37,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
i
++
}
return
input
[
:
i
],
input
[
i
:
]
,
nil
return
input
[
:
i
],
input
[
i
:
]
}
// parseOptions parses the raw string values of the given options
...
...
commands/cli/parse_test.go
View file @
4986600e
...
...
@@ -35,10 +35,7 @@ func TestOptionParsing(t *testing.T) {
t
.
Error
(
"Should have failed (duplicate option name)"
)
}
path
,
args
,
err
:=
parsePath
([]
string
{
"test"
,
"beep"
,
"boop"
},
cmd
)
if
err
!=
nil
{
t
.
Error
(
"Should have passed"
)
}
path
,
args
:=
parsePath
([]
string
{
"test"
,
"beep"
,
"boop"
},
cmd
)
if
len
(
path
)
!=
1
||
path
[
0
]
!=
"test"
{
t
.
Error
(
"Returned path was defferent than expected: %v"
,
path
)
}
...
...
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