Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
f8be2681
Commit
f8be2681
authored
10 years ago
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Changed Request#Arguments to a []string
parent
9dcf2167
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
16 deletions
+11
-16
commands/cli/parse.go
commands/cli/parse.go
+2
-2
commands/http/client.go
commands/http/client.go
+1
-6
commands/http/parse.go
commands/http/parse.go
+1
-1
commands/request.go
commands/request.go
+7
-7
No files found.
commands/cli/parse.go
View file @
f8be2681
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
commands/http/client.go
View file @
f8be2681
...
...
@@ -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
)
}
}
...
...
This diff is collapsed.
Click to expand it.
commands/http/parse.go
View file @
f8be2681
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
commands/request.go
View file @
f8be2681
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment