func (x *Command) Add(sigs ...string) {
	defer x.Unlock()
	x.Lock()
	if x.Commands == nil {
		x.Commands = util.NewStringMap()
	}
	for _, sig := range sigs {
		aliases := strings.Split(sig, "|")
		name := aliases[len(aliases)-1]
		if !valid.Name(name) {
			panic(m_invalid_name)
		}
		x.Commands.Set(name, name)
		for _, alias := range aliases {
			if !valid.Name(alias) {
				panic(m_invalid_name)
			}
			x.Commands.Set(alias, name)
		}
	}
}
Add adds the list of Command signatures passed. A command signature
consists of one or more more aliases separated by a bar (|) with the
final word being the name of the actual Command.  Aliases are
a useful way to provide shortcuts when tab completion is not
available and should generally be considered for every Command.
Single letter aliases are common and encouraged.

Note that Add does not validate inclusion in the internal Register
(Reg) since in many cases there may not yet be a Register entry, and
in the case of actions handled entirely by the Command itself there
never will be.  See Command.Commands and Command.Run.
package cmdbox
import (
	"fmt"
	"strings"
	"sync"
	"github.com/rwxrob/cmdbox/util"
	"github.com/rwxrob/cmdbox/valid"
)
type Command struct {
	Name        string          `json:"name,omitempty" yaml:",omitempty"`
	Summary     string          `json:"summary,omitempty" yaml:",omitempty"`
	Usage       string          `json:"usage,omitempty" yaml:",omitempty"`
	Version     string          `json:"version,omitempty" yaml:",omitempty"`
	Copyright   string          `json:"copyright,omitempty" yaml:",omitempty"`
	License     string          `json:"license,omitempty" yaml:",omitempty"`
	Description string          `json:"description,omitempty" yaml:",omitempty"`
	Site        string          `json:"git,omitempty" yaml:",omitempty"`
	Source      string          `json:"git,omitempty" yaml:",omitempty"`
	Issues      string          `json:"issues,omitempty" yaml:",omitempty"`
	Commands    *util.StringMap `json:"commands,omitempty" yaml:",omitempty"`
	Params      []string        `json:"params,omitempty" yaml:",omitempty"`
	Default     string          `json:"default,omitempty" yaml:",omitempty"`
	CompFunc   CompFunc `json:"-" yaml:"-"`
	Caller     *Command `json:"-" yaml:"-"`
	Method     Method   `json:"-" yaml:"-"`
	sync.Mutex `json:"-" yaml:"-"`
}
type Method func(args []string) error
func NewCommand(name string, a ...string) *Command {
	x := new(Command)
	if !valid.Name(name) && name[len(name)-1] != '_' {
		SyntaxErrorPanic(fmt.Sprintf(m_invalid_name, name))
	}
	x.Name = name
	x.Commands = util.NewStringMap()
	x.Default = "help"
	if len(a) > 0 {
		x.Add(a...)
	}
	x.UpdateUsage()
	return x
}
func (x *Command) Title() string {
	switch {
	case len(x.Summary) > 0 && len(x.Version) > 0:
		return x.Name + " (" + x.Version + ")" + " - " + x.Summary
	case len(x.Summary) > 0:
		return x.Name + " - " + x.Summary
	default:
		return x.Name
	}
}
func (x *Command) Legal() string {
	switch {
	case len(x.Copyright) > 0 && len(x.License) > 0 && len(x.Version) > 0:
		return x.Name + " " + x.Version + "\n" +
			x.Copyright + "\nLicense " + x.License
	case len(x.Copyright) > 0 && len(x.License) > 0:
		return x.Name + "\n" + x.Copyright + "\nLicense " + x.License
	case len(x.Copyright) > 0:
		return x.Name + "\n" + x.Copyright
	default:
		return ""
	}
}
func (x *Command) UpdateUsage() {
	names := x.Commands.Keys()
	if len(names) > 0 {
		x.Usage = "[" + strings.Join(names, "|") + "]"
	}
}
func (x Command) JSON() string { return util.ToJSON(x) }
func (x Command) YAML() string { return util.ToYAML(x) }
func (x Command) Print() { fmt.Println(util.ToYAML(x)) }
func (x Command) String() string { return util.ToJSON(x) }