diff --git a/commands/cli/parse.go b/commands/cli/parse.go index 614a0b16f..1f00c3161 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -127,7 +127,7 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) { return opts, args, nil } -func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursive bool) ([]interface{}, []cmds.File, error) { +func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursive bool) ([]string, []cmds.File, error) { // check if stdin is coming from terminal or is being piped in if stdin != nil { stat, err := stdin.Stat() @@ -163,7 +163,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi return nil, nil, fmt.Errorf("Expected %v arguments, got %v", len(argDefs), numInputs) } - stringArgs := make([]interface{}, 0, numInputs) + stringArgs := make([]string, 0, numInputs) fileArgs := make([]cmds.File, 0, numInputs) argDefIndex := 0 // the index of the current argument definition diff --git a/commands/http/client.go b/commands/http/client.go index 3dcf6e9c3..3cbc41153 100644 --- a/commands/http/client.go +++ b/commands/http/client.go @@ -11,7 +11,6 @@ import ( cmds "github.com/jbenet/go-ipfs/commands" config "github.com/jbenet/go-ipfs/config" - u "github.com/jbenet/go-ipfs/util" ) const ( @@ -109,11 +108,7 @@ func getQuery(req cmds.Request) (string, error) { } if argDef.Type == cmds.ArgString { - str, ok := arg.(string) - if !ok { - return "", u.ErrCast() - } - query.Add("arg", str) + query.Add("arg", arg) } } diff --git a/commands/http/parse.go b/commands/http/parse.go index 8022782ed..d2d8725b6 100644 --- a/commands/http/parse.go +++ b/commands/http/parse.go @@ -51,7 +51,7 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) { // count the number of provided argument values valCount := len(stringArgs) - args := make([]interface{}, valCount) + args := make([]string, valCount) valIndex := 0 for _, argDef := range cmd.Arguments { diff --git a/commands/request.go b/commands/request.go index beb990d51..d13a06673 100644 --- a/commands/request.go +++ b/commands/request.go @@ -61,8 +61,8 @@ type Request interface { Option(name string) *OptionValue Options() optMap SetOption(name string, val interface{}) - Arguments() []interface{} - SetArguments([]interface{}) + Arguments() []string + SetArguments([]string) Files() File SetFiles(File) Context() *Context @@ -76,7 +76,7 @@ type Request interface { type request struct { path []string options optMap - arguments []interface{} + arguments []string files File cmd *Command ctx Context @@ -145,11 +145,11 @@ func (r *request) SetOption(name string, val interface{}) { } // Arguments returns the arguments slice -func (r *request) Arguments() []interface{} { +func (r *request) Arguments() []string { return r.arguments } -func (r *request) SetArguments(args []interface{}) { +func (r *request) SetArguments(args []string) { r.arguments = args } @@ -258,7 +258,7 @@ func NewEmptyRequest() (Request, error) { // NewRequest returns a request initialized with given arguments // An non-nil error will be returned if the provided option values are invalid -func NewRequest(path []string, opts optMap, args []interface{}, file File, cmd *Command, optDefs map[string]Option) (Request, error) { +func NewRequest(path []string, opts optMap, args []string, file File, cmd *Command, optDefs map[string]Option) (Request, error) { if path == nil { path = make([]string, 0) } @@ -266,7 +266,7 @@ func NewRequest(path []string, opts optMap, args []interface{}, file File, cmd * opts = make(map[string]interface{}) } if args == nil { - args = make([]interface{}, 0) + args = make([]string, 0) } if optDefs == nil { optDefs = make(map[string]Option)