@cryptotaxi247 / kubo / commits / d7e9afc80

commands: Use global options when registering and calling commands

Matt Bell committed Oct 10, 2014 at 11:41 UTC d7e9afc801a8160b50d5642685c663ddd47e7822
1 file changed +2
commands/command.go
+2
@@ -21,6 +21,7 @@ func (c *Command) Register(id string, sub *Command) error {
21
22 // check for duplicate option names (only checks downwards)
23 names := make(map[string]bool)
24 + globalCommand.checkOptions(names)
25 c.checkOptions(names)
26 err := sub.checkOptions(names)
27 if err != nil {
@@ -39,6 +40,7 @@ func (c *Command) Register(id string, sub *Command) error {
40 func (c *Command) Call(path []string, req *Request) (interface{}, error) {
41 options := make([]Option, len(c.Options))
42 copy(options, c.Options)
43 + options = append(options, globalOptions...)
44 cmd := c
45
46 if path != nil {