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
e14471f5
Commit
e14471f5
authored
Nov 11, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Use better variable name for parseArgs value index
parent
54812306
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
commands/cli/parse.go
commands/cli/parse.go
+9
-9
No files found.
commands/cli/parse.go
View file @
e14471f5
...
...
@@ -134,40 +134,40 @@ func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
}
}
j
:=
0
valueIndex
:=
0
// the index of the current stringArgs value
for
_
,
argDef
:=
range
cmd
.
Arguments
{
// skip optional argument definitions if there aren't sufficient remaining values
if
len
(
stringArgs
)
-
j
<=
lenRequired
&&
!
argDef
.
Required
{
if
len
(
stringArgs
)
-
valueIndex
<=
lenRequired
&&
!
argDef
.
Required
{
continue
}
else
if
argDef
.
Required
{
lenRequired
--
}
if
j
>=
len
(
stringArgs
)
{
if
valueIndex
>=
len
(
stringArgs
)
{
break
}
if
argDef
.
Variadic
{
for
_
,
arg
:=
range
stringArgs
[
j
:
]
{
for
_
,
arg
:=
range
stringArgs
[
valueIndex
:
]
{
var
err
error
args
,
err
=
appendArg
(
args
,
argDef
,
arg
)
if
err
!=
nil
{
return
nil
,
err
}
j
++
valueIndex
++
}
}
else
{
var
err
error
args
,
err
=
appendArg
(
args
,
argDef
,
stringArgs
[
j
])
args
,
err
=
appendArg
(
args
,
argDef
,
stringArgs
[
valueIndex
])
if
err
!=
nil
{
return
nil
,
err
}
j
++
valueIndex
++
}
}
if
len
(
stringArgs
)
-
j
>
0
{
args
=
append
(
args
,
make
([]
interface
{},
len
(
stringArgs
)
-
j
))
if
len
(
stringArgs
)
-
valueIndex
>
0
{
args
=
append
(
args
,
make
([]
interface
{},
len
(
stringArgs
)
-
valueIndex
))
}
return
args
,
nil
...
...
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