package command import ( "flag" "io" ) // A node represents a command. type node struct { child, next *node name, usage string out io.Writer logf LogFunc // Names of commands preceding node. prefix []string // Short user-facing representations of flags received by node. suffix []string f HandlerFunc set *flag.FlagSet } // adopt adds v as the last child of n. func (n *node) adopt(v *node) bool { if n.child != nil { return n.child.append(v) } n.child = v return true } // append adds v as the last sibling of n. func (n *node) append(v *node) bool { if n.name == v.name { return false } if n.next != nil { return n.next.append(v) } n.next = v return true }