func (a *Author) String() string {
	e := ""
	if a.Email != "" {
		e = " <" + a.Email + ">"
	}
	return fmt.Sprintf("%v%v", a.Name, e)
}
String makes Author comply to the Stringer interface, to allow an easy print in the templating process
package cli
import (
	"context"
	"flag"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"sort"
	"time"
)
var (
	changeLogURL            = "https://github.com/urfave/cli/blob/master/docs/CHANGELOG.md"
	appActionDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-action-signature", changeLogURL)
	contactSysadmin         = "This is an error in the application.  Please contact the distributor of this application if this is not you."
	errInvalidActionType    = NewExitError("ERROR invalid Action type. "+
		fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error).  %s", contactSysadmin)+
		fmt.Sprintf("See %s", appActionDeprecationURL), 2)
)
type App struct {
	Name string
	HelpName string
	Usage string
	UsageText string
	ArgsUsage string
	Version string
	Description string
	Commands []*Command
	Flags []Flag
	EnableBashCompletion bool
	HideHelp bool
	HideHelpCommand bool
	HideVersion bool
	categories CommandCategories
	BashComplete BashCompleteFunc
	Before BeforeFunc
	After AfterFunc
	Action ActionFunc
	CommandNotFound CommandNotFoundFunc
	OnUsageError OnUsageErrorFunc
	Compiled time.Time
	Authors []*Author
	Copyright string
	Writer io.Writer
	ErrWriter io.Writer
	ExitErrHandler ExitErrHandlerFunc
	Metadata map[string]interface{}
	ExtraInfo func() map[string]string
	CustomAppHelpTemplate string
	UseShortOptionHandling bool
	didSetup bool
}
func compileTime() time.Time {
	info, err := os.Stat(os.Args[0])
	if err != nil {
		return time.Now()
	}
	return info.ModTime()
}
func NewApp() *App {
	return &App{
		Name:         filepath.Base(os.Args[0]),
		HelpName:     filepath.Base(os.Args[0]),
		Usage:        "A new cli application",
		UsageText:    "",
		BashComplete: DefaultAppComplete,
		Action:       helpCommand.Action,
		Compiled:     compileTime(),
		Writer:       os.Stdout,
	}
}
func (a *App) Setup() {
	if a.didSetup {
		return
	}
	a.didSetup = true
	if a.Name == "" {
		a.Name = filepath.Base(os.Args[0])
	}
	if a.HelpName == "" {
		a.HelpName = filepath.Base(os.Args[0])
	}
	if a.Usage == "" {
		a.Usage = "A new cli application"
	}
	if a.Version == "" {
		a.HideVersion = true
	}
	if a.BashComplete == nil {
		a.BashComplete = DefaultAppComplete
	}
	if a.Action == nil {
		a.Action = helpCommand.Action
	}
	if a.Compiled == (time.Time{}) {
		a.Compiled = compileTime()
	}
	if a.Writer == nil {
		a.Writer = os.Stdout
	}
	var newCommands []*Command
	for _, c := range a.Commands {
		if c.HelpName == "" {
			c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
		}
		newCommands = append(newCommands, c)
	}
	a.Commands = newCommands
	if a.Command(helpCommand.Name) == nil && !a.HideHelp {
		if !a.HideHelpCommand {
			a.appendCommand(helpCommand)
		}
		if HelpFlag != nil {
			a.appendFlag(HelpFlag)
		}
	}
	if !a.HideVersion {
		a.appendFlag(VersionFlag)
	}
	a.categories = newCommandCategories()
	for _, command := range a.Commands {
		a.categories.AddCommand(command.Category, command)
	}
	sort.Sort(a.categories.(*commandCategories))
	if a.Metadata == nil {
		a.Metadata = make(map[string]interface{})
	}
	if a.Writer == nil {
		a.Writer = os.Stdout
	}
}
func (a *App) newFlagSet() (*flag.FlagSet, error) {
	return flagSet(a.Name, a.Flags)
}
func (a *App) useShortOptionHandling() bool {
	return a.UseShortOptionHandling
}
func (a *App) Run(arguments []string) (err error) {
	return a.RunContext(context.Background(), arguments)
}
func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
	a.Setup()
	shellComplete, arguments := checkShellCompleteFlag(a, arguments)
	set, err := a.newFlagSet()
	if err != nil {
		return err
	}
	err = parseIter(set, a, arguments[1:], shellComplete)
	nerr := normalizeFlags(a.Flags, set)
	context := NewContext(a, set, &Context{Context: ctx})
	if nerr != nil {
		_, _ = fmt.Fprintln(a.Writer, nerr)
		_ = ShowAppHelp(context)
		return nerr
	}
	context.shellComplete = shellComplete
	if checkCompletions(context) {
		return nil
	}
	if err != nil {
		if a.OnUsageError != nil {
			err := a.OnUsageError(context, err, false)
			a.handleExitCoder(context, err)
			return err
		}
		_, _ = fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error())
		_ = ShowAppHelp(context)
		return err
	}
	if !a.HideHelp && checkHelp(context) {
		_ = ShowAppHelp(context)
		return nil
	}
	if !a.HideVersion && checkVersion(context) {
		ShowVersion(context)
		return nil
	}
	cerr := checkRequiredFlags(a.Flags, context)
	if cerr != nil {
		_ = ShowAppHelp(context)
		return cerr
	}
	if a.After != nil {
		defer func() {
			if afterErr := a.After(context); afterErr != nil {
				if err != nil {
					err = newMultiError(err, afterErr)
				} else {
					err = afterErr
				}
			}
		}()
	}
	if a.Before != nil {
		beforeErr := a.Before(context)
		if beforeErr != nil {
			_, _ = fmt.Fprintf(a.Writer, "%v\n\n", beforeErr)
			_ = ShowAppHelp(context)
			a.handleExitCoder(context, beforeErr)
			err = beforeErr
			return err
		}
	}
	args := context.Args()
	if args.Present() {
		name := args.First()
		c := a.Command(name)
		if c != nil {
			return c.Run(context)
		}
	}
	if a.Action == nil {
		a.Action = helpCommand.Action
	}
	err = a.Action(context)
	a.handleExitCoder(context, err)
	return err
}
func (a *App) RunAndExitOnError() {
	if err := a.Run(os.Args); err != nil {
		_, _ = fmt.Fprintln(a.errWriter(), err)
		OsExiter(1)
	}
}
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
	a.Setup()
	var newCmds []*Command
	for _, c := range a.Commands {
		if c.HelpName == "" {
			c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
		}
		newCmds = append(newCmds, c)
	}
	a.Commands = newCmds
	set, err := a.newFlagSet()
	if err != nil {
		return err
	}
	err = parseIter(set, a, ctx.Args().Tail(), ctx.shellComplete)
	nerr := normalizeFlags(a.Flags, set)
	context := NewContext(a, set, ctx)
	if nerr != nil {
		_, _ = fmt.Fprintln(a.Writer, nerr)
		_, _ = fmt.Fprintln(a.Writer)
		if len(a.Commands) > 0 {
			_ = ShowSubcommandHelp(context)
		} else {
			_ = ShowCommandHelp(ctx, context.Args().First())
		}
		return nerr
	}
	if checkCompletions(context) {
		return nil
	}
	if err != nil {
		if a.OnUsageError != nil {
			err = a.OnUsageError(context, err, true)
			a.handleExitCoder(context, err)
			return err
		}
		_, _ = fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error())
		_ = ShowSubcommandHelp(context)
		return err
	}
	if len(a.Commands) > 0 {
		if checkSubcommandHelp(context) {
			return nil
		}
	} else {
		if checkCommandHelp(ctx, context.Args().First()) {
			return nil
		}
	}
	cerr := checkRequiredFlags(a.Flags, context)
	if cerr != nil {
		_ = ShowSubcommandHelp(context)
		return cerr
	}
	if a.After != nil {
		defer func() {
			afterErr := a.After(context)
			if afterErr != nil {
				a.handleExitCoder(context, err)
				if err != nil {
					err = newMultiError(err, afterErr)
				} else {
					err = afterErr
				}
			}
		}()
	}
	if a.Before != nil {
		beforeErr := a.Before(context)
		if beforeErr != nil {
			a.handleExitCoder(context, beforeErr)
			err = beforeErr
			return err
		}
	}
	args := context.Args()
	if args.Present() {
		name := args.First()
		c := a.Command(name)
		if c != nil {
			return c.Run(context)
		}
	}
	err = a.Action(context)
	a.handleExitCoder(context, err)
	return err
}
func (a *App) Command(name string) *Command {
	for _, c := range a.Commands {
		if c.HasName(name) {
			return c
		}
	}
	return nil
}
func (a *App) VisibleCategories() []CommandCategory {
	ret := []CommandCategory{}
	for _, category := range a.categories.Categories() {
		if visible := func() CommandCategory {
			if len(category.VisibleCommands()) > 0 {
				return category
			}
			return nil
		}(); visible != nil {
			ret = append(ret, visible)
		}
	}
	return ret
}
func (a *App) VisibleCommands() []*Command {
	var ret []*Command
	for _, command := range a.Commands {
		if !command.Hidden {
			ret = append(ret, command)
		}
	}
	return ret
}
func (a *App) VisibleFlags() []Flag {
	return visibleFlags(a.Flags)
}
func (a *App) errWriter() io.Writer {
	if a.ErrWriter == nil {
		return ErrWriter
	}
	return a.ErrWriter
}
func (a *App) appendFlag(fl Flag) {
	if !hasFlag(a.Flags, fl) {
		a.Flags = append(a.Flags, fl)
	}
}
func (a *App) appendCommand(c *Command) {
	if !hasCommand(a.Commands, c) {
		a.Commands = append(a.Commands, c)
	}
}
func (a *App) handleExitCoder(context *Context, err error) {
	if a.ExitErrHandler != nil {
		a.ExitErrHandler(context, err)
	} else {
		HandleExitCoder(err)
	}
}
type Author struct {
	Name  string  
	Email string  
}