Detect and panic if command is setup as it's own child.

This commit is contained in:
spf13 2013-09-10 18:28:58 -04:00
parent 90b975fd8e
commit 7ba2df2eff

View file

@ -158,6 +158,9 @@ func (c *Command) ResetCommands() {
// Add one or many commands as children of this
func (c *Command) AddCommand(cmds ...*Command) {
for i, x := range cmds {
if cmds[i] == c {
panic("Command can't be a child of itself")
}
cmds[i].parent = c
c.commands = append(c.commands, x)
}