commands: request: Added Values map
Matt Bell committed
Jan 21, 2015 at 17:37 UTC
4a6aec645e028c601f1ddb01a99e86409d670533
1 file changed
+8
-1
commands/request.go
+8
-1
@@ -77,6 +77,7 @@ type Request interface {
77
Context() *Context
78
SetContext(Context)
79
Command() *Command
80
+ Values() map[string]interface{}
81
82
ConvertOptions() error
83
}
@@ -89,6 +90,7 @@ type request struct {
90
cmd *Command
91
ctx Context
92
optionDefs map[string]Option
93
+ values map[string]interface{}
94
}
95
96
// Path returns the command path of this request
@@ -208,6 +210,10 @@ var converters = map[reflect.Kind]converter{
210
},
211
}
212
213
+func (r *request) Values() map[string]interface{} {
214
+ return r.values
215
+}
216
+
217
func (r *request) ConvertOptions() error {
218
for k, v := range r.options {
219
opt, ok := r.optionDefs[k]
@@ -275,7 +281,8 @@ func NewRequest(path []string, opts optMap, args []string, file files.File, cmd
281
}
282
283
ctx := Context{Context: context.TODO()}
278
- req := &request{path, opts, args, file, cmd, ctx, optDefs}
284
+ values := make(map[string]interface{})
285
+ req := &request{path, opts, args, file, cmd, ctx, optDefs, values}
286
err := req.ConvertOptions()
287
if err != nil {
288
return nil, err