NewRequest() - export OptMap type
Henry committed
Mar 8, 2015 at 12:14 UTC
86b34a2af60ee700feb17768bfb3513e63d32544
1 file changed
+9
-9
commands/request.go
+9
-9
@@ -15,7 +15,7 @@ import (
15
u "github.com/jbenet/go-ipfs/util"
16
)
17
18
-type optMap map[string]interface{}
18
+type OptMap map[string]interface{}
19
20
type Context struct {
21
// this Context is temporary. Will be replaced soon, as we get
@@ -68,9 +68,9 @@ func (c *Context) NodeWithoutConstructing() *core.IpfsNode {
68
type Request interface {
69
Path() []string
70
Option(name string) *OptionValue
71
- Options() optMap
71
+ Options() OptMap
72
SetOption(name string, val interface{})
73
- SetOptions(opts map[string]interface{}) error
73
+ SetOptions(opts OptMap) error
74
Arguments() []string
75
SetArguments([]string)
76
Files() files.File
@@ -86,7 +86,7 @@ type Request interface {
86
87
type request struct {
88
path []string
89
- options optMap
89
+ options OptMap
90
arguments []string
91
files files.File
92
cmd *Command
@@ -122,8 +122,8 @@ func (r *request) Option(name string) *OptionValue {
122
}
123
124
// Options returns a copy of the option map
125
-func (r *request) Options() optMap {
126
- output := make(optMap)
125
+func (r *request) Options() OptMap {
126
+ output := make(OptMap)
127
for k, v := range r.options {
128
output[k] = v
129
}
@@ -151,7 +151,7 @@ func (r *request) SetOption(name string, val interface{}) {
151
}
152
153
// SetOptions sets the option values, unsetting any values that were previously set
154
-func (r *request) SetOptions(opts map[string]interface{}) error {
154
+func (r *request) SetOptions(opts OptMap) error {
155
r.options = opts
156
return r.ConvertOptions()
157
}
@@ -273,12 +273,12 @@ func NewEmptyRequest() (Request, error) {
273
274
// NewRequest returns a request initialized with given arguments
275
// An non-nil error will be returned if the provided option values are invalid
276
-func NewRequest(path []string, opts optMap, args []string, file files.File, cmd *Command, optDefs map[string]Option) (Request, error) {
276
+func NewRequest(path []string, opts OptMap, args []string, file files.File, cmd *Command, optDefs map[string]Option) (Request, error) {
277
if path == nil {
278
path = make([]string, 0)
279
}
280
if opts == nil {
281
- opts = make(map[string]interface{})
281
+ opts = make(OptMap)
282
}
283
if args == nil {
284
args = make([]string, 0)