commands: Added Command#Get

This commit is contained in:
Matt Bell 2014-10-15 17:19:16 -07:00 committed by Juan Batiz-Benet
parent c054fb3655
commit d2176c05eb

View File

@ -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))