package cmd type Set []*Command func NewSet() Set { return Set{} } func (s *Set) Add(c *Command) { *s = append(*s, c) } func (s Set) Get(name string) (*Command, bool) { for _, c := range s { if c.Name == name { return c, true } for _, alias := range c.Aliases { if alias == name { return c, true } } } return nil, false } func (s Set) MaxNameWidth() int { max := 0 for _, f := range s { if w := len(f.Name); w > max { max = w } } return max } func (s Set) Len() int { return len(s) }