func lastConfig(app *cli.App) {
	sort.Sort(cli.FlagsByName(app.Flags))
	sort.Sort(cli.CommandsByName(app.Commands))
}
lastConfig - Add last configuration right before start CLI application
package app
import (
	"os"
	"sort"
	"github.com/swisscom/korp/autocompletion"
	"github.com/swisscom/korp/pull"
	"github.com/swisscom/korp/push"
	"github.com/swisscom/korp/scan"
	log "github.com/sirupsen/logrus"
	"github.com/urfave/cli"
)
const (
	version = "1.0.2"
)
type CliApp struct {
	app *cli.App
}
func Create() *CliApp {
	app := cli.NewApp()
	addGlobaConfig(app)
	addGlobalFlags(app)
	addBefore(app)
	addCommands(app)
	lastConfig(app)
	return &CliApp{
		app: app,
	}
}
func addGlobaConfig(app *cli.App) {
	app.Name = "korp"
	app.Usage = "push images to a corporate registry based on Kubernetes yaml files"
	app.Version = version
	app.EnableBashCompletion = true
}
func addGlobalFlags(app *cli.App) {
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:   "debug, d",
			Usage:  "switch on debug log output",
			EnvVar: "KORP_GLOBAL_DEBUG",
		},
		cli.StringFlag{
			Name:     "config, c",
			Usage:    "Load configuration from `FILE`",
			EnvVar:   "KORP_GLOBAL_CONFIG",
			FilePath: "./config",
		},
	}
}
func addBefore(app *cli.App) {
	app.Before = func(c *cli.Context) error {
		if c.Bool("debug") {
			log.SetLevel(log.DebugLevel)
		}
		return nil
	}
}
func addCommands(app *cli.App) {
	app.Commands = []cli.Command{
		*scan.BuildCommand(),
		*pull.BuildCommand(),
		*push.BuildCommand(),
		*autocompletion.BuildCommand(),
	}
}