-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (49 loc) · 1.07 KB
/
main.go
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
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
"gopkg.in/yaml.v2"
"log"
"os"
"syncute-go/connections"
"syncute-go/helpers"
"syncute-go/models"
)
var (
remoteAddress *string
token *string
repoPath *string
)
func init() {
remoteAddress = flag.String("address", "", "Remote Address")
token = flag.String("token", "", "Access Token")
repoPath = flag.String("path", "", "Repository Path")
}
func main() {
flag.Parse()
f, err := os.Open("config.yml")
if err != nil {
}
defer f.Close()
var cfg models.Config
decoder := yaml.NewDecoder(f)
err = decoder.Decode(&cfg)
if err != nil {
log.Fatal("Error in reading config.yml ", err)
}
if *remoteAddress == "" {
*remoteAddress = cfg.Server.RemoteAddress
}
if *token == "" {
*token = cfg.Server.AccessToken
}
if *repoPath == "" {
*repoPath = cfg.Client.RepositoryPath
}
log.Printf("Config=> RemoteAddress: %s, RepositoryPath: %s\n", *remoteAddress, *repoPath)
helpers.CheckRepo(cfg.Client.RepositoryPath)
client := connections.Client{
RemoteAddress: *remoteAddress,
Token: *token,
}
client.Start()
}