diff options
author | Slack Coder <slackcoder@server.ky> | 2024-10-16 17:59:08 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2024-10-16 17:58:29 -0500 |
commit | 8f9152ecae99489ed44b0456d6eda544905d83a3 (patch) | |
tree | 8faf82c467360a40dd7183a81272521898c66a47 | |
parent | fecc42849871ec040aac004bcf80ff85e97d4d87 (diff) | |
download | mirror-8f9152ecae99489ed44b0456d6eda544905d83a3.tar.xz |
Support versioning
-rw-r--r-- | cmd/mirror/main.go | 12 |
1 files changed, 11 insertions, 1 deletions
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) |