commands: request: Added Values map

This commit is contained in:
Matt Bell 2015-01-21 17:37:05 -08:00
parent 8ca8d6ef71
commit 4a6aec645e

View File

@ -77,6 +77,7 @@ type Request interface {
Context() *Context
SetContext(Context)
Command() *Command
Values() map[string]interface{}
ConvertOptions() error
}
@ -89,6 +90,7 @@ type request struct {
cmd *Command
ctx Context
optionDefs map[string]Option
values map[string]interface{}
}
// Path returns the command path of this request
@ -208,6 +210,10 @@ var converters = map[reflect.Kind]converter{
},
}
func (r *request) Values() map[string]interface{} {
return r.values
}
func (r *request) ConvertOptions() error {
for k, v := range r.options {
opt, ok := r.optionDefs[k]
@ -275,7 +281,8 @@ func NewRequest(path []string, opts optMap, args []string, file files.File, cmd
}
ctx := Context{Context: context.TODO()}
req := &request{path, opts, args, file, cmd, ctx, optDefs}
values := make(map[string]interface{})
req := &request{path, opts, args, file, cmd, ctx, optDefs, values}
err := req.ConvertOptions()
if err != nil {
return nil, err