From 14c4a2d4c9ae4cc8a53e54f57ab6ba10a432fb80 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 7 Mar 2018 15:23:24 +0000 Subject: [PATCH] main: Add a CLI version option Add a `--version` command-line option to allow the agent version to be queried. Fixes #212. Signed-off-by: James O. D. Hunt --- agent.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agent.go b/agent.go index 47841762b..d8f7c153a 100644 --- a/agent.go +++ b/agent.go @@ -207,6 +207,10 @@ func init() { var Version = "unknown" func main() { + if len(os.Args) == 2 && os.Args[1] == "--version" { + fmt.Printf("%s version %s\n", name, Version) + os.Exit(0) + } agentLog.Logger.Formatter = &logrus.JSONFormatter{TimestampFormat: time.RFC3339Nano} config := newConfig(defaultLogLevel)