Commit 405cfd97 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/http: Made parser/client handle variadic arguments

parent 2c8fc856
......@@ -49,8 +49,15 @@ func Send(req cmds.Request) (cmds.Response, error) {
}
args := req.Arguments()
argDefs := req.Command().Arguments
var argDef cmds.Argument
for i, arg := range args {
if req.Command().Arguments[i].Type == cmds.ArgString {
if i < len(argDefs) {
argDef = argDefs[i]
}
if argDef.Type == cmds.ArgString {
query += "&arg=" + arg.(string)
} else {
......
......@@ -36,17 +36,18 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
// Note that the argument handling here is dumb, it does not do any error-checking.
// (Arguments are further processed when the request is passed to the command to run)
args := make([]interface{}, len(cmd.Arguments))
for i, arg := range cmd.Arguments {
args := make([]interface{}, 0)
for _, arg := range cmd.Arguments {
if arg.Type == cmds.ArgString {
if len(stringArgs) > 0 {
args[i] = stringArgs[0]
for j := 0; len(stringArgs) > 0 && arg.Variadic || j == 0; j++ {
args = append(args, stringArgs[0])
stringArgs = stringArgs[1:]
}
} else {
// TODO: create multipart streams for file args
args[i] = r.Body
args = append(args, r.Body)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment