@cryptotaxi247 / kubo / commits / 1b9b60331

commands/http: Cleaned up argument handling in Parse

Matt Bell committed Nov 4, 2014 at 00:42 UTC 1b9b60331fb04986a1cb5243918844cfcc21de4b
1 file changed +9 -1
commands/http/parse.go
+9 -1
@@ -45,9 +45,17 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
45
46 for _, arg := range cmd.Arguments {
47 if arg.Type == cmds.ArgString {
48 - for j := 0; len(stringArgs) > 0 && arg.Variadic || j == 0; j++ {
48 + if arg.Variadic {
49 + for _, s := range stringArgs {
50 + args = append(args, s)
51 + }
52 +
53 + } else if len(stringArgs) > 0 {
54 args = append(args, stringArgs[0])
55 stringArgs = stringArgs[1:]
56 +
57 + } else {
58 + break
59 }
60
61 } else {