@cryptotaxi247 / kubo / commits / cb72868ab

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

Matt Bell committed Nov 5, 2014 at 16:22 UTC cb72868ab4775dc619717bed33cd025b2fd52862
2 files changed +4
commands/cli/parse.go
+2
@@ -132,6 +132,8 @@ func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
132 // skip optional argument definitions if there aren't sufficient remaining values
133 if len(stringArgs)-j <= lenRequired && !argDef.Required {
134 continue
135 + } else if argDef.Required {
136 + lenRequired--
137 }
138
139 if j >= len(stringArgs) {
commands/http/parse.go
+2
@@ -60,6 +60,8 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
60 // skip optional argument definitions if there aren't sufficient remaining values
61 if valCount <= lenRequired && !argDef.Required {
62 continue
63 + } else if argDef.Required {
64 + lenRequired--
65 }
66
67 if argDef.Type == cmds.ArgString {