func (a *App) Run(arguments []string) error {
	if a.Command(helpCommand.Name) == nil && !a.HideHelp {
		a.Commands = append(a.Commands, helpCommand)
		a.appendFlag(HelpFlag)
	}
	if a.EnableBashCompletion {
		a.appendFlag(BashCompletionFlag)
	}
	a.appendFlag(VersionFlag)
	set := flagSet(a.Name, a.Flags)
	set.SetOutput(ioutil.Discard)
	err := set.Parse(arguments[1:])
	nerr := normalizeFlags(a.Flags, set)
	if nerr != nil {
		fmt.Println(nerr)
		context := NewContext(a, set, set)
		ShowAppHelp(context)
		fmt.Println("")
		return nerr
	}
	context := NewContext(a, set, set)
	if err != nil {
		fmt.Printf("Incorrect Usage.\n\n")
		ShowAppHelp(context)
		fmt.Println("")
		return err
	}
	if checkCompletions(context) {
		return nil
	}
	if checkHelp(context) {
		return nil
	}
	if checkVersion(context) {
		return nil
	}
	if a.Before != nil {
		err := a.Before(context)
		if err != nil {
			return err
		}
	}
	args := context.Args()
	if args.Present() {
		name := args.First()
		c := a.Command(name)
		if c != nil {
			return c.Run(context)
		}
	}
	a.Action(context)
	return nil
}
Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
package cli
import (
	"fmt"
	"io/ioutil"
	"os"
	"time"
)
type App struct {
	Name string
	Usage string
	Version string
	Commands []Command
	Flags []Flag
	EnableBashCompletion bool
	HideHelp bool
	BashComplete func(context *Context)
	Before func(context *Context) error
	Action func(context *Context)
	CommandNotFound func(context *Context, command string)
	Compiled time.Time
	Author string
	Email string
}
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:         os.Args[0],
		Usage:        "A new cli application",
		Version:      "0.0.0",
		BashComplete: DefaultAppComplete,
		Action:       helpCommand.Action,
		Compiled:     compileTime(),
	}
}