Commit 2c8fc856 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/cli: Made parser handle variadic arguments

parent e8d0cbff
...@@ -108,19 +108,19 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) { ...@@ -108,19 +108,19 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) {
// Note that the argument handling here is dumb, it does not do any error-checking. // 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) // (Arguments are further processed when the request is passed to the command to run)
func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) { func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
args := make([]interface{}, len(cmd.Arguments)) var argDef cmds.Argument
args := make([]interface{}, len(stringArgs))
for i, arg := range cmd.Arguments { for i, arg := range stringArgs {
// TODO: handle variadic args if i < len(cmd.Arguments) {
if i >= len(stringArgs) { argDef = cmd.Arguments[i]
break
} }
if arg.Type == cmds.ArgString { if argDef.Type == cmds.ArgString {
args[i] = stringArgs[i] args[i] = arg
} else { } else {
in, err := os.Open(stringArgs[i]) in, err := os.Open(arg)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
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