From 2d40f0a36399234aa4e7edef6a3bb76117540918 Mon Sep 17 00:00:00 2001 From: Jan Fuhrer Date: Sat, 28 Dec 2024 17:59:23 +0100 Subject: [PATCH] feat: add flag -version --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 1f14e9a..932f14a 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "net/http" "os" @@ -31,9 +32,15 @@ func main() { "Loglevel") ignoreIndividuals = flag.String("openvpn.ignore-individuals", "false", "If ignoring metrics for individuals") + showVersion = flag.Bool("version", false, "Show version and exit") ) flag.Parse() + if *showVersion { + fmt.Printf("OpenVPN Exporter Version: %s, Commit: %s, Build Time: %s\n", Version, Commit, BuildTime) + os.Exit(0) + } + // log build information log.Printf("INFO: Starting OpenVPN Exporter %s, commit %s, built at %s", Version, Commit, BuildTime)