-
Notifications
You must be signed in to change notification settings - Fork 2
/
params.go
52 lines (44 loc) · 1.23 KB
/
params.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
47
48
49
50
51
52
package core
import (
"flag"
"fmt"
"os"
"github.com/hexbotio/hex/models"
)
func Params(config *models.Config) {
// capture the flag
configFile := flag.String("config", "", "Location of the config file")
validate := flag.Bool("validate", false, "Validate the config file")
showVersion := flag.Bool("version", false, "Version of HexBot")
startup := flag.Bool("startup", false, "Startup file for HexBot")
flag.Parse()
// set the config values
config.ConfigFile = *configFile
config.Validate = *validate
// operate on any flags
if *showVersion {
fmt.Print("HexBot " + config.Version + "\n")
os.Exit(0)
}
// startup file
if *startup {
fmt.Print("\n")
fmt.Print("1. Create file: /etc/systemd/system/hex.service\n")
fmt.Print("--------------------------------\n")
fmt.Print("[Unit]\n")
fmt.Print("Description=HexBot\n")
fmt.Print("\n")
fmt.Print("[Service]\n")
fmt.Print("Type=simple\n")
fmt.Print("ExecStart=/usr/local/bin/hex\n")
fmt.Print("Restart=on-failure\n")
fmt.Print("\n")
fmt.Print("[Install]\n")
fmt.Print("WantedBy=multi-user.target\n")
fmt.Print("--------------------------------\n")
fmt.Print("\n")
fmt.Print("2. Run: systemctl enable hex.service\n")
fmt.Print("\n")
os.Exit(0)
}
}