1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 12:20:03 +08:00

commands: Fixed Request#CheckArguments not erroring when required arguments were missing

This commit is contained in:
Matt Bell
2014-11-03 00:09:39 -08:00
committed by Juan Batiz-Benet
parent 405cfd9762
commit 586a019fbf

View File

@ -107,7 +107,19 @@ var converters = map[reflect.Kind]converter{
func (r *request) CheckArguments(args []Argument) error {
var argDef Argument
for i, arg := range r.arguments {
var length int
if len(r.arguments) > len(args) {
length = len(r.arguments)
} else {
length = len(args)
}
for i := 0; i < length; i++ {
var arg interface{}
if len(r.arguments) > i {
arg = r.arguments[i]
}
if i < len(args) {
argDef = args[i]
} else if !argDef.Variadic {