Add flag to print version
This commit is contained in:
parent
ac8ab9ef43
commit
1ad5bcef14
17
main.go
17
main.go
@ -7,8 +7,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LogDebug will control whether debug messsages should be logged
|
var (
|
||||||
var LogDebug bool = false
|
// LogDebug will control whether debug messsages should be logged
|
||||||
|
LogDebug = false
|
||||||
|
|
||||||
|
// version of minitor being run
|
||||||
|
version = "dev"
|
||||||
|
)
|
||||||
|
|
||||||
func checkMonitors(config *Config) {
|
func checkMonitors(config *Config) {
|
||||||
for _, monitor := range config.Monitors {
|
for _, monitor := range config.Monitors {
|
||||||
@ -59,8 +64,16 @@ func checkMonitors(config *Config) {
|
|||||||
func main() {
|
func main() {
|
||||||
// Get debug flag
|
// Get debug flag
|
||||||
flag.BoolVar(&LogDebug, "debug", false, "Enables debug logs (default: false)")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
|
// Print version if flag is provided
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Println("Minitor version:", version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load configuration
|
||||||
config, err := LoadConfig("config.yml")
|
config, err := LoadConfig("config.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error loading config: %v", err)
|
log.Fatalf("Error loading config: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user