Commit 4a6aec64 authored by Matt Bell's avatar Matt Bell

commands: request: Added Values map

parent 8ca8d6ef
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment