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 ""
	}
}
Legal returns a single line with the combined values of the
Name, Version, Copyright, and License. If Version is empty or nil an
empty string is returned instead. Legal() is used by the
version builtin command to aggregate all the version information into
a single output.
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
	}
}