-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
}
}