commands: Fixed parser argument bug (TODO: better test coverage for command parsers)

This commit is contained in:
Matt Bell 2014-11-05 16:22:12 -08:00 committed by Juan Batiz-Benet
parent b6aad53d86
commit cb72868ab4
2 changed files with 4 additions and 0 deletions

View File

@ -132,6 +132,8 @@ func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
// skip optional argument definitions if there aren't sufficient remaining values
if len(stringArgs)-j <= lenRequired && !argDef.Required {
continue
} else if argDef.Required {
lenRequired--
}
if j >= len(stringArgs) {

View File

@ -60,6 +60,8 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
// skip optional argument definitions if there aren't sufficient remaining values
if valCount <= lenRequired && !argDef.Required {
continue
} else if argDef.Required {
lenRequired--
}
if argDef.Type == cmds.ArgString {