1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-19 01:39:35 +08:00

commands: Fail earlier for arg count checking (by doing it in CLI req parser)

This commit is contained in:
Matt Bell
2014-11-16 22:44:34 -08:00
parent 032e9c292f
commit 9dcf21673d
2 changed files with 15 additions and 16 deletions

View File

@ -199,14 +199,6 @@ func (c *Command) CheckArguments(req Request) error {
// TODO: check file arguments
args := req.Arguments()
argDefs := c.Arguments
// if we have more arg values provided than argument definitions,
// and the last arg definition is not variadic (or there are no definitions), return an error
notVariadic := len(argDefs) == 0 || !argDefs[len(argDefs)-1].Variadic
if notVariadic && len(args) > len(argDefs) {
return fmt.Errorf("Expected %v arguments, got %v", len(argDefs), len(args))
}
// count required argument definitions
numRequired := 0