2019-01-09 16:54:15 +00:00
|
|
|
package cmds
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-11-12 04:20:19 +00:00
|
|
|
"os"
|
2020-12-04 05:04:55 +00:00
|
|
|
"runtime"
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/version"
|
2020-08-29 19:46:55 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-08-30 03:30:07 +00:00
|
|
|
Debug bool
|
2023-01-31 20:57:48 +00:00
|
|
|
DebugFlag = &cli.BoolFlag{
|
2020-08-30 03:30:07 +00:00
|
|
|
Name: "debug",
|
2020-09-03 17:39:46 +00:00
|
|
|
Usage: "(logging) Turn on debug logs",
|
2020-08-30 03:30:07 +00:00
|
|
|
Destination: &Debug,
|
|
|
|
EnvVar: version.ProgramUpper + "_DEBUG",
|
|
|
|
}
|
2023-01-31 20:57:48 +00:00
|
|
|
PreferBundledBin = &cli.BoolFlag{
|
2022-11-22 21:43:16 +00:00
|
|
|
Name: "prefer-bundled-bin",
|
|
|
|
Usage: "(experimental) Prefer bundled userspace binaries over host binaries",
|
|
|
|
}
|
2019-01-09 16:54:15 +00:00
|
|
|
)
|
|
|
|
|
2019-11-12 04:20:19 +00:00
|
|
|
func init() {
|
|
|
|
// hack - force "file,dns" lookup order if go dns is used
|
|
|
|
if os.Getenv("RES_OPTIONS") == "" {
|
|
|
|
os.Setenv("RES_OPTIONS", " ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
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)
|
2020-12-04 05:04:55 +00:00
|
|
|
fmt.Printf("go version %s\n", runtime.Version())
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
2020-08-29 19:46:55 +00:00
|
|
|
app.Flags = []cli.Flag{
|
2020-08-30 03:30:07 +00:00
|
|
|
DebugFlag,
|
2024-07-29 19:22:50 +00:00
|
|
|
DataDirFlag,
|
2020-08-29 19:46:55 +00:00
|
|
|
}
|
2020-08-30 03:30:07 +00:00
|
|
|
|
|
|
|
return app
|
|
|
|
}
|