blob: e823039318bbc223f625dd6830de14b0edc81c15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package main
import (
"flag"
"fmt"
"log"
"os"
"git.server.ky/slackcoder/mirror/internal/service"
)
// Program version
var Version string
type Flags struct {
Config 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
}
func exitOnError(err error) {
if err != nil {
log.Printf("%s", err)
os.Exit(-1)
}
}
func main() {
flags := ParseFlags()
if flags.Version {
fmt.Println(Version)
os.Exit(0)
}
cfg, err := service.ReadConfig(flags.Config)
exitOnError(err)
srv, err := service.NewService(cfg)
exitOnError(err)
err = srv.Run()
exitOnError(err)
}
|