From 8f9152ecae99489ed44b0456d6eda544905d83a3 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Wed, 16 Oct 2024 17:59:08 -0500 Subject: Support versioning --- cmd/mirror/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/mirror/main.go b/cmd/mirror/main.go index 8276a10..e823039 100644 --- a/cmd/mirror/main.go +++ b/cmd/mirror/main.go @@ -2,21 +2,26 @@ package main import ( "flag" + "fmt" "log" "os" "git.server.ky/slackcoder/mirror/internal/service" ) +// Program version +var Version string + type Flags struct { Config string - Mirrors string + Version bool } func ParseFlags() *Flags { var flags Flags flag.StringVar(&flags.Config, "config", "/etc/mirror/mirror.toml", "configuration file") + flag.BoolVar(&flags.Version, "version", false, "print version") flag.Parse() return &flags @@ -32,6 +37,11 @@ func exitOnError(err error) { func main() { flags := ParseFlags() + if flags.Version { + fmt.Println(Version) + os.Exit(0) + } + cfg, err := service.ReadConfig(flags.Config) exitOnError(err) -- cgit v1.2.3