k3s/pkg/cli/cmds/root.go

40 lines
707 B
Go
Raw Normal View History

2019-01-09 16:54:15 +00:00
package cmds
import (
"fmt"
"github.com/rancher/k3s/pkg/version"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
debug bool
)
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = appName
app.Usage = "Kubernetes, but small and simple"
2019-02-08 04:28:09 +00:00
app.Version = fmt.Sprintf("%s (%s)", version.Version, version.GitCommit)
2019-01-09 16:54:15 +00:00
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version %s\n", app.Name, app.Version)
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Turn on debug logs",
Destination: &debug,
},
}
app.Before = func(ctx *cli.Context) error {
if debug {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
return app
}