From 6989297a6625cb6fc0fe66cd2c73e92fdbfa94d7 Mon Sep 17 00:00:00 2001 From: postmannen Date: Wed, 12 Apr 2023 09:56:08 +0200 Subject: [PATCH] add version flag --- cmd/steward/main.go | 2 +- configuration_flags.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/steward/main.go b/cmd/steward/main.go index 50fcf39..74f71a4 100644 --- a/cmd/steward/main.go +++ b/cmd/steward/main.go @@ -27,7 +27,7 @@ func main() { //defer profile.Start(profile.MemProfile, profile.MemProfileRate(1)).Stop() c := steward.NewConfiguration() - err := c.CheckFlags() + err := c.CheckFlags(version) if err != nil { log.Printf("%v\n", err) return diff --git a/configuration_flags.go b/configuration_flags.go index 0beabde..41ee0c3 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -597,7 +597,7 @@ func checkConfigValues(cf ConfigurationFromFile) Configuration { } // CheckFlags will parse all flags -func (c *Configuration) CheckFlags() error { +func (c *Configuration) CheckFlags(version string) error { // Create an empty default config var fc Configuration @@ -691,8 +691,15 @@ func (c *Configuration) CheckFlags() error { purgeBufferDB := flag.Bool("purgeBufferDB", false, "true/false, purge the incoming buffer db and all it's state") + ver := flag.Bool("version", false, "print version and exit") + flag.Parse() + if *ver { + fmt.Printf("version %v\n", version) + os.Exit(0) + } + // Check that mandatory flag values have been set. switch { case c.NodeName == "":