@cryptotaxi247 / kubo / commits / 20591c7e6

commands: Made SetOption override existing values (even if they used a different alias)

Matt Bell committed Nov 10, 2014 at 21:11 UTC 20591c7e64917dd8970fecd301501623c14ed3f7
1 file changed +15
commands/request.go
+15
@@ -81,6 +81,21 @@ func (r *request) Options() map[string]interface{} {
81
82 // SetOption sets the value of the option for given name.
83 func (r *request) SetOption(name string, val interface{}) {
84 + // find the option with the specified name
85 + option, found := r.optionDefs[name]
86 + if !found {
87 + return
88 + }
89 +
90 + // try all the possible names, if we already have a value then set over it
91 + for _, n := range option.Names {
92 + val, found := r.options[n]
93 + if found {
94 + r.options[n] = val
95 + return
96 + }
97 + }
98 +
99 r.options[name] = val
100 }
101