From cb72868ab4775dc619717bed33cd025b2fd52862 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 5 Nov 2014 16:22:12 -0800 Subject: [PATCH] commands: Fixed parser argument bug (TODO: better test coverage for command parsers) --- commands/cli/parse.go | 2 ++ commands/http/parse.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/commands/cli/parse.go b/commands/cli/parse.go index a26b4b78f..8972fa96d 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -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) { diff --git a/commands/http/parse.go b/commands/http/parse.go index b23240739..979bacb78 100644 --- a/commands/http/parse.go +++ b/commands/http/parse.go @@ -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 {