func (a *App) addCommand(cmd *Command, addHelpFlag bool) {
	err := cmd.validate()
	if err != nil {
		panic(err)
	}
	cmd.registerFlagsAndArgs(addHelpFlag)
	a.commands.Add(cmd)
}
addCommand adds a new command.
If addHelpFlag is true, a help flag is automatically
added to the command which displays its usage on use.
Panics on error.
package grumble
import (
	"fmt"
	"io"
	"os"
	"strings"
	"github.com/desertbit/closer/v3"
	shlex "github.com/desertbit/go-shlex"
	"github.com/desertbit/readline"
	"github.com/fatih/color"
)
type App struct {
	closer.Closer
	rl            *readline.Instance
	config        *Config
	commands      Commands
	isShell       bool
	currentPrompt string
	flags   Flags
	flagMap FlagMap
	args Args
	initHook  func(a *App, flags FlagMap) error
	shellHook func(a *App) error
	printHelp        func(a *App, shell bool)
	printCommandHelp func(a *App, cmd *Command, shell bool)
	interruptHandler func(a *App, count int)
	printASCIILogo   func(a *App)
}
func New(c *Config) (a *App) {
	c.SetDefaults()
	err := c.Validate()
	if err != nil {
		panic(err)
	}
	a = &App{
		Closer:           closer.New(),
		config:           c,
		currentPrompt:    c.prompt(),
		flagMap:          make(FlagMap),
		printHelp:        defaultPrintHelp,
		printCommandHelp: defaultPrintCommandHelp,
		interruptHandler: defaultInterruptHandler,
	}
	a.flags.Bool("h", "help", false, "display help")
	a.flags.BoolL("nocolor", false, "disable color output")
	if c.Flags != nil {
		c.Flags(&a.flags)
	}
	return
}
func (a *App) SetPrompt(p string) {
	if !a.config.NoColor {
		p = a.config.PromptColor.Sprint(p)
	}
	a.currentPrompt = p
}
func (a *App) SetDefaultPrompt() {
	a.currentPrompt = a.config.prompt()
}
func (a *App) IsShell() bool {
	return a.isShell
}
func (a *App) Config() *Config {
	return a.config
}
func (a *App) Commands() *Commands {
	return &a.commands
}
func (a *App) PrintError(err error) {
	if a.config.NoColor {
		a.Printf("error: %v\n", err)
	} else {
		a.config.ErrorColor.Fprint(a, "error: ")
		a.Printf("%v\n", err)
	}
}
func (a *App) Print(args ...interface{}) (int, error) {
	return fmt.Fprint(a, args...)
}
func (a *App) Printf(format string, args ...interface{}) (int, error) {
	return fmt.Fprintf(a, format, args...)
}
func (a *App) Println(args ...interface{}) (int, error) {
	return fmt.Fprintln(a, args...)
}
func (a *App) OnInit(f func(a *App, flags FlagMap) error) {
	a.initHook = f
}
func (a *App) OnShell(f func(a *App) error) {
	a.shellHook = f
}
func (a *App) SetInterruptHandler(f func(a *App, count int)) {
	a.interruptHandler = f
}
func (a *App) SetPrintHelp(f func(a *App, shell bool)) {
	a.printHelp = f
}
func (a *App) SetPrintCommandHelp(f func(a *App, c *Command, shell bool)) {
	a.printCommandHelp = f
}
func (a *App) SetPrintASCIILogo(f func(a *App)) {
	a.printASCIILogo = func(a *App) {
		if !a.config.NoColor {
			a.config.ASCIILogoColor.Set()
			defer color.Unset()
		}
		f(a)
	}
}
func (a *App) Write(p []byte) (int, error) {
	return a.Stdout().Write(p)
}
func (a *App) Stdout() io.Writer {
	if a.rl != nil {
		return a.rl.Stdout()
	}
	return os.Stdout
}
func (a *App) Stderr() io.Writer {
	if a.rl != nil {
		return a.rl.Stderr()
	}
	return os.Stderr
}
func (a *App) AddCommand(cmd *Command) {
	a.addCommand(cmd, true)
}