aboutsummaryrefslogtreecommitdiffsponsor
path: root/cmd
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-04-08 15:29:11 -0500
committerSlack Coder <slackcoder@server.ky>2024-07-18 11:47:49 -0500
commitae748859be8d6d3ed3c0929770f0c287ab6d6460 (patch)
tree284d3bf3d7fa496a9d334391eac996affc5a01b9 /cmd
parentc2267767ca8ed06018d26a45b483c44b7c4234cf (diff)
downloadmirror-ae748859be8d6d3ed3c0929770f0c287ab6d6460.tar.xz
Port to Golang
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mirror/main.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/cmd/mirror/main.go b/cmd/mirror/main.go
new file mode 100644
index 0000000..e8a7f6c
--- /dev/null
+++ b/cmd/mirror/main.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "flag"
+ "log"
+ "os"
+
+ "git.server.ky/slackcoder/mirror/internal/service"
+)
+
+type Flags struct {
+ Config string
+ Mirrors string
+}
+
+func ParseFlags() *Flags {
+ var flags Flags
+
+ flag.StringVar(&flags.Config, "config", "/etc/mirror/config.json", "configuration file")
+
+ flag.Parse()
+ return &flags
+}
+
+func exitOnError(err error) {
+ if err != nil {
+ log.Printf("%s", err)
+ os.Exit(-1)
+ }
+}
+
+func main() {
+ flags := ParseFlags()
+
+ var cfg service.Config
+ err := service.ApplyFileConfig(&cfg, flags.Config)
+ exitOnError(err)
+
+ srv, err := service.NewService(&cfg)
+ exitOnError(err)
+
+ err = srv.Run()
+ exitOnError(err)
+}