commands: s/j/valueIndex/
Matt Bell committed
Nov 11, 2014 at 16:49 UTC
50751617b68086fc5602ae6d0af78727d9d80083
1 file changed
+7
-7
commands/command.go
+7
-7
@@ -167,18 +167,18 @@ func (c *Command) CheckArguments(req Request) error {
167
}
168
169
// iterate over the arg definitions
170
- j := 0
170
+ valueIndex := 0 // the index of the current value (in `args`)
171
for _, argDef := range c.Arguments {
172
// skip optional argument definitions if there aren't sufficient remaining values
173
- if len(args)-j <= numRequired && !argDef.Required {
173
+ if len(args)-valueIndex <= numRequired && !argDef.Required {
174
continue
175
}
176
177
// the value for this argument definition. can be nil if it wasn't provided by the caller
178
var v interface{}
179
- if j < len(args) {
180
- v = args[j]
181
- j++
179
+ if valueIndex < len(args) {
180
+ v = args[valueIndex]
181
+ valueIndex++
182
}
183
184
err := checkArgValue(v, argDef)
@@ -187,8 +187,8 @@ func (c *Command) CheckArguments(req Request) error {
187
}
188
189
// any additional values are for the variadic arg definition
190
- if argDef.Variadic && j < len(args)-1 {
191
- for _, val := range args[j:] {
190
+ if argDef.Variadic && valueIndex < len(args)-1 {
191
+ for _, val := range args[valueIndex:] {
192
err := checkArgValue(val, argDef)
193
if err != nil {
194
return err