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

commands: request: Added Values map

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