mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-18 04:40:03 +02:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/eosswedenorg/thalos/internal/config"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
var VersionString string = "dev"
|
|
|
|
var rootCmd *cobra.Command
|
|
|
|
func init() {
|
|
rootCmd = &cobra.Command{
|
|
Use: "thalos-server",
|
|
FParseErrWhitelist: cobra.FParseErrWhitelist{
|
|
UnknownFlags: true,
|
|
},
|
|
Version: VersionString,
|
|
Run: serverCmd,
|
|
}
|
|
|
|
rootCmd.SetHelpTemplate(
|
|
`{{ .Use | trimTrailingWhitespaces}} v{{.Version}}
|
|
|
|
{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}
|
|
`)
|
|
rootCmd.SetVersionTemplate(`{{with .Name}}{{printf "%s " .}}{{end}}{{printf "v%s" .Version}}` + "\n")
|
|
|
|
flags := pflag.FlagSet{}
|
|
|
|
flags.StringP("config", "c", "./config.yml", "Config file to read")
|
|
flags.StringP("level", "L", "info", "Log level to use")
|
|
flags.StringP("pid", "p", "", "Where to write process id")
|
|
flags.BoolP("no-state-cache", "n", false, "Force the application to take start block from config/api")
|
|
|
|
rootCmd.PersistentFlags().AddFlagSet(&flags)
|
|
rootCmd.PersistentFlags().AddFlagSet(config.GetFlags())
|
|
}
|
|
|
|
func main() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|