mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 03:19:47 +08:00
commands: Changed Request#Arguments to a []string
This commit is contained in:
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user