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
c0b28dc1
Commit
c0b28dc1
authored
Oct 20, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Added input stream field to Request
parent
b10fc2cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
commands/request.go
commands/request.go
+11
-3
No files found.
commands/request.go
View file @
c0b28dc1
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"fmt"
"fmt"
"reflect"
"reflect"
"strconv"
"strconv"
"io"
)
)
type
optMap
map
[
string
]
interface
{}
type
optMap
map
[
string
]
interface
{}
...
@@ -14,6 +15,7 @@ type Request interface {
...
@@ -14,6 +15,7 @@ type Request interface {
Option
(
name
string
)
(
interface
{},
bool
)
Option
(
name
string
)
(
interface
{},
bool
)
SetOption
(
name
string
,
val
interface
{})
SetOption
(
name
string
,
val
interface
{})
Arguments
()
[]
string
Arguments
()
[]
string
Stream
()
io
.
Reader
ConvertOptions
(
options
map
[
string
]
Option
)
error
ConvertOptions
(
options
map
[
string
]
Option
)
error
}
}
...
@@ -22,6 +24,7 @@ type request struct {
...
@@ -22,6 +24,7 @@ type request struct {
path
[]
string
path
[]
string
options
optMap
options
optMap
arguments
[]
string
arguments
[]
string
in
io
.
Reader
}
}
// Path returns the command path of this request
// Path returns the command path of this request
...
@@ -45,6 +48,11 @@ func (r *request) Arguments() []string {
...
@@ -45,6 +48,11 @@ func (r *request) Arguments() []string {
return
r
.
arguments
return
r
.
arguments
}
}
// Stream returns the input stream Reader
func
(
r
*
request
)
Stream
()
io
.
Reader
{
return
r
.
in
}
type
converter
func
(
string
)
(
interface
{},
error
)
type
converter
func
(
string
)
(
interface
{},
error
)
var
converters
=
map
[
reflect
.
Kind
]
converter
{
var
converters
=
map
[
reflect
.
Kind
]
converter
{
...
@@ -111,11 +119,11 @@ func (r *request) ConvertOptions(options map[string]Option) error {
...
@@ -111,11 +119,11 @@ func (r *request) ConvertOptions(options map[string]Option) error {
// NewEmptyRequest initializes an empty request
// NewEmptyRequest initializes an empty request
func
NewEmptyRequest
()
Request
{
func
NewEmptyRequest
()
Request
{
return
NewRequest
(
nil
,
nil
,
nil
)
return
NewRequest
(
nil
,
nil
,
nil
,
nil
)
}
}
// NewRequest returns a request initialized with given arguments
// NewRequest returns a request initialized with given arguments
func
NewRequest
(
path
[]
string
,
opts
optMap
,
args
[]
string
)
Request
{
func
NewRequest
(
path
[]
string
,
opts
optMap
,
args
[]
string
,
in
io
.
Reader
)
Request
{
if
path
==
nil
{
if
path
==
nil
{
path
=
make
([]
string
,
0
)
path
=
make
([]
string
,
0
)
}
}
...
@@ -125,5 +133,5 @@ func NewRequest(path []string, opts optMap, args []string) Request {
...
@@ -125,5 +133,5 @@ func NewRequest(path []string, opts optMap, args []string) Request {
if
args
==
nil
{
if
args
==
nil
{
args
=
make
([]
string
,
0
)
args
=
make
([]
string
,
0
)
}
}
return
&
request
{
path
,
opts
,
args
}
return
&
request
{
path
,
opts
,
args
,
in
}
}
}
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