-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (49 loc) · 1.33 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
package main
import (
"Logseq_connector/controller/calendar"
"Logseq_connector/controller/gitlab"
"Logseq_connector/controller/paperless"
"encoding/json"
"github.com/shomali11/util/xconditions"
"log"
"os"
)
type Config struct {
Graph map[string]string
Calendar []calendar.Config
Gitlab []gitlab.Config
Paperless []paperless.Config
}
var config *Config
func main() {
var path string
if len(os.Args) > 1 {
path = os.Args[1] + xconditions.IfThenElse(string(os.Args[1][len(os.Args[1])-1:]) == "/", "", "/").(string)
}
getConfig(path + "config.json")
// region Calendar
for _, instance := range config.Calendar {
log.Println("get Calendar:", instance.Name)
calendar.GetCalendar(instance, path+config.Graph[instance.Graph])
}
// endregion
// region gitlab
for _, instance := range config.Gitlab {
log.Println("get Gitlab:", instance.Name)
gitlab.Process(instance, path+config.Graph[instance.Graph]+"/pages/gitlab___")
}
// endregion
// region Paperless
for _, instance := range config.Paperless {
log.Println("get Paperless:", instance.Name)
paperless.Process(instance, path+config.Graph[instance.Graph]+"/pages/documents___paperless___")
}
// endregion
}
func getConfig(filename string) {
f, err := os.ReadFile(filename)
if err != nil {
log.Println(err)
}
json.Unmarshal(f, &config) //nolint:errcheck
}