aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-10-16 17:59:08 -0500
committerSlack Coder <slackcoder@server.ky>2024-10-16 17:58:29 -0500
commit8f9152ecae99489ed44b0456d6eda544905d83a3 (patch)
tree8faf82c467360a40dd7183a81272521898c66a47
parentfecc42849871ec040aac004bcf80ff85e97d4d87 (diff)
downloadmirror-8f9152ecae99489ed44b0456d6eda544905d83a3.tar.xz
Support versioning
-rw-r--r--cmd/mirror/main.go12
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)