mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
commands: Added Request#Options so consumers can iterate through provided options
This commit is contained in:

committed by
Juan Batiz-Benet

parent
e8b37acda3
commit
a65c99e71e
@ -13,6 +13,7 @@ type optMap map[string]interface{}
|
||||
type Request interface {
|
||||
Path() []string
|
||||
Option(name string) (interface{}, bool)
|
||||
Options() map[string]interface{}
|
||||
SetOption(name string, val interface{})
|
||||
Arguments() []string
|
||||
Stream() io.Reader
|
||||
@ -39,6 +40,15 @@ func (r *request) Option(name string) (interface{}, bool) {
|
||||
return val, err
|
||||
}
|
||||
|
||||
// Options returns a copy of the option map
|
||||
func (r *request) Options() map[string]interface{} {
|
||||
output := make(optMap)
|
||||
for k, v := range r.options {
|
||||
output[k] = v
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
// SetOption sets the value of the option for given name.
|
||||
func (r *request) SetOption(name string, val interface{}) {
|
||||
r.options[name] = val
|
||||
|
Reference in New Issue
Block a user