From d2176c05eb2c823387c60fd75f4bffd14ee56bf9 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 15 Oct 2014 17:19:16 -0700 Subject: [PATCH] commands: Added Command#Get --- commands/command.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commands/command.go b/commands/command.go index 5db0eb9e3..449ce2aa6 100644 --- a/commands/command.go +++ b/commands/command.go @@ -91,6 +91,14 @@ func (c *Command) Resolve(path []string) ([]*Command, error) { return cmds, nil } +func (c *Command) Get(path []string) (*Command, error) { + cmds, err := c.Resolve(path) + if err != nil { + return nil, err + } + return cmds[len(cmds) - 1], nil +} + // GetOptions gets the options in the given path of commands func (c *Command) GetOptions(path []string) (map[string]Option, error) { options := make([]Option, len(c.Options))