mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
49 lines
890 B
Go
49 lines
890 B
Go
package cmds
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/rancher/k3s/pkg/version"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var (
|
|
debug bool
|
|
)
|
|
|
|
func init() {
|
|
// hack - force "file,dns" lookup order if go dns is used
|
|
if os.Getenv("RES_OPTIONS") == "" {
|
|
os.Setenv("RES_OPTIONS", " ")
|
|
}
|
|
}
|
|
|
|
func NewApp() *cli.App {
|
|
app := cli.NewApp()
|
|
app.Name = appName
|
|
app.Usage = "Kubernetes, but small and simple"
|
|
app.Version = fmt.Sprintf("%s (%s)", version.Version, version.GitCommit)
|
|
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,
|
|
EnvVar: "K3S_DEBUG",
|
|
},
|
|
}
|
|
|
|
app.Before = func(ctx *cli.Context) error {
|
|
if debug {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
return app
|
|
}
|