From d2748259cb0a39507c8a6021fc924b8e0fb133d7 Mon Sep 17 00:00:00 2001 From: Adora Laura Kalb Date: Fri, 26 Jul 2024 10:54:33 +0200 Subject: [PATCH] add version flag --- cmd/mailcow-admin-aliases/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/mailcow-admin-aliases/main.go b/cmd/mailcow-admin-aliases/main.go index 61d2c2c..42d6a30 100644 --- a/cmd/mailcow-admin-aliases/main.go +++ b/cmd/mailcow-admin-aliases/main.go @@ -17,14 +17,23 @@ import ( "github.com/spf13/pflag" ) +var Version string + func main() { - quiet := pflag.BoolP("quiet", "q", false, "Disable logging") - verbose := pflag.Bool("debug", false, "Enable debug logging (beats --quiet)") + quietFlag := pflag.BoolP("quiet", "q", false, "Disable logging") + verboseFlag := pflag.Bool("debug", false, "Enable debug logging (beats --quiet)") + versionFlag := pflag.BoolP("version", "v", false, "Show version information") pflag.BoolVarP(&configuration.DryRun, "dry-run", "d", false, "Show what this application *would* do") pflag.StringVarP(&configuration.ConfigFile, "config", "c", "", "Path to config file (default: $WorkDir/config.yaml)") pflag.Parse() - logging.NewSlogLogger(*quiet, *verbose) + + if *versionFlag { + fmt.Println("mailcow-admin-aliases " + Version) + return + } + + logging.NewSlogLogger(*quietFlag, *verboseFlag) var cfg configuration.Config err := cfg.LoadFromDisk()