Add flag to print version

This commit is contained in:
IamTheFij 2019-10-04 16:17:20 -07:00
parent ac8ab9ef43
commit 1ad5bcef14

17
main.go
View File

@ -7,8 +7,13 @@ import (
"time"
)
// LogDebug will control whether debug messsages should be logged
var LogDebug bool = false
var (
// LogDebug will control whether debug messsages should be logged
LogDebug = false
// version of minitor being run
version = "dev"
)
func checkMonitors(config *Config) {
for _, monitor := range config.Monitors {
@ -59,8 +64,16 @@ func checkMonitors(config *Config) {
func main() {
// Get debug flag
flag.BoolVar(&LogDebug, "debug", false, "Enables debug logs (default: false)")
var showVersion = flag.Bool("version", false, "Display the version of minitor and exit")
flag.Parse()
// Print version if flag is provided
if *showVersion {
fmt.Println("Minitor version:", version)
return
}
// Load configuration
config, err := LoadConfig("config.yml")
if err != nil {
log.Fatalf("Error loading config: %v", err)