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()