-
Notifications
You must be signed in to change notification settings - Fork 3
/
root.go
35 lines (28 loc) · 989 Bytes
/
root.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
package cmd
import (
"fmt"
"github.com/slotopol/server/config"
"github.com/spf13/cobra"
)
const rootShort = "Slots games backend"
const rootLong = `This application implements web server and reels scanner for slots games.`
var (
rootCmd = &cobra.Command{
Use: config.AppName,
Version: config.BuildVers,
Short: rootShort,
Long: rootLong,
}
)
func init() {
cobra.OnInitialize(config.InitConfig)
var flags = rootCmd.PersistentFlags()
flags.StringVarP(&config.CfgFile, "config", "c", "", "config file (default is config/slot.yaml at executable location)")
flags.StringVarP(&config.SqlPath, "sqlite", "q", "", "sqlite databases path (default same as config file path)")
flags.BoolVarP(&config.DevMode, "devmode", "d", false, "start application in developer mode")
rootCmd.SetVersionTemplate(fmt.Sprintf("version: %s, builton: %s", config.BuildVers, config.BuildTime))
}
// Execute executes the root command.
func Execute() error {
return rootCmd.Execute()
}