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
66b0727d
Commit
66b0727d
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
commands/cli: Renamed parse functions to parse*
parent
1b356158
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
commands/cli/parse.go
commands/cli/parse.go
+4
-4
commands/cli/parse_test.go
commands/cli/parse_test.go
+2
-2
No files found.
commands/cli/parse.go
View file @
66b0727d
...
...
@@ -8,12 +8,12 @@ import (
)
func
Parse
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
,
map
[
string
]
string
,
error
)
{
opts
,
input
,
err
:=
o
ptions
(
input
,
root
)
opts
,
input
,
err
:=
parseO
ptions
(
input
,
root
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
path
,
args
,
err
:=
path
(
input
,
root
)
path
,
args
,
err
:=
pa
rsePa
th
(
input
,
root
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
...
...
@@ -23,7 +23,7 @@ func Parse(input []string, root *commands.Command) ([]string, []string, map[stri
// options parses the raw string values of the given options
// returns the parsed options as strings, along with the CLI input minus option blobs
func
o
ptions
(
input
[]
string
,
root
*
commands
.
Command
)
(
map
[
string
]
string
,
[]
string
,
error
)
{
func
parseO
ptions
(
input
[]
string
,
root
*
commands
.
Command
)
(
map
[
string
]
string
,
[]
string
,
error
)
{
opts
:=
make
(
map
[
string
]
string
)
cleanInput
:=
make
([]
string
,
0
)
...
...
@@ -97,7 +97,7 @@ func options(input []string, root *commands.Command) (map[string]string, []strin
}
// path takes the command line (without options) and splits it into the command path and arguments
func
path
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
,
error
)
{
func
pa
rsePa
th
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
,
error
)
{
cmd
:=
root
i
:=
0
...
...
This diff is collapsed.
Click to expand it.
commands/cli/parse_test.go
View file @
66b0727d
...
...
@@ -8,7 +8,7 @@ import (
)
func
TestOptionParsing
(
t
*
testing
.
T
)
{
opts
,
input
,
err
:=
o
ptions
([]
string
{
"test"
,
"--beep"
,
"--boop=
\"
5"
,
"lol
\"
"
,
"test2"
,
"-cV"
},
nil
)
opts
,
input
,
err
:=
parseO
ptions
([]
string
{
"test"
,
"--beep"
,
"--boop=
\"
5"
,
"lol
\"
"
,
"test2"
,
"-cV"
},
nil
)
/*for k, v := range opts {
fmt.Printf("%s: %s\n", k, v)
}
...
...
@@ -25,7 +25,7 @@ func TestOptionParsing(t *testing.T) {
cmd
:=
&
commands
.
Command
{}
cmd
.
Register
(
"test"
,
&
commands
.
Command
{})
path
,
args
,
err
:=
path
([]
string
{
"test"
,
"beep"
,
"boop"
},
cmd
)
path
,
args
,
err
:=
pa
rsePa
th
([]
string
{
"test"
,
"beep"
,
"boop"
},
cmd
)
if
err
!=
nil
{
t
.
Error
(
"Should have passed"
)
}
...
...
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