From 5d7be016a7804480d419abb7730ef6a319859d4c Mon Sep 17 00:00:00 2001 From: "George H. Sun" Date: Fri, 8 Mar 2024 18:29:22 +0800 Subject: [PATCH] Provide a flag to show the current version. (#47) `--version` will should the build version and exit, which is useful for debugging. --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index f31c8df..a3c4636 100644 --- a/main.go +++ b/main.go @@ -106,6 +106,7 @@ func init() { pflag.Bool("start-disabled", false, "Whether or not to start the server disabled") pflag.Bool("debug", false, "Start the server in debug mode") pflag.Bool("once", false, "Run Ansible Puller just once, then exit") + pflag.Bool("version", false, "Print the build version, then exit") err := viper.ReadInConfig() if err != nil { @@ -287,6 +288,11 @@ func ansibleRun() error { } func main() { + if viper.GetBool("version") { + fmt.Println(Version) + return + } + if viper.GetBool("once") { if err := ansibleRun(); err != nil { logrus.Fatalln("Ansible run failed due to: " + err.Error())