commands: Added Command#Get
Matt Bell committed
Oct 15, 2014 at 17:19 UTC
d2176c05eb2c823387c60fd75f4bffd14ee56bf9
1 file changed
+8
commands/command.go
+8
@@ -91,6 +91,14 @@ func (c *Command) Resolve(path []string) ([]*Command, error) {
91
return cmds, nil
92
}
93
94
+func (c *Command) Get(path []string) (*Command, error) {
95
+ cmds, err := c.Resolve(path)
96
+ if err != nil {
97
+ return nil, err
98
+ }
99
+ return cmds[len(cmds) - 1], nil
100
+}
101
+
102
// GetOptions gets the options in the given path of commands
103
func (c *Command) GetOptions(path []string) (map[string]Option, error) {
104
options := make([]Option, len(c.Options))