/
main.go
55 lines (41 loc) · 1.09 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
package main
import (
"context"
"embed"
"encoding/json"
"flag"
"os"
"github.com/f-taxes/csv_import/conf"
"github.com/f-taxes/csv_import/ctl"
"github.com/f-taxes/csv_import/global"
g "github.com/f-taxes/csv_import/grpc_client"
"github.com/f-taxes/csv_import/web"
"github.com/kataras/golog"
)
//go:embed frontend-dist/*
var WebAssets embed.FS
func init() {
manifestContent, err := os.ReadFile("./manifest.json")
if err != nil {
golog.Fatalf("Failed to read manifest file: %v", err)
os.Exit(1)
}
err = json.Unmarshal(manifestContent, &global.Plugin)
if err != nil {
golog.Fatalf("Failed to parse manifest: %v", err)
os.Exit(1)
}
}
func main() {
grpcAddress := flag.String("grpc-addr", "127.0.0.1:4222", "GRPC address of the f-taxes server that the plugin will attempt to connect to.")
flag.Parse()
ctx := context.Background()
g.GrpcClient = g.NewFTaxesClient(*grpcAddress)
err := g.GrpcClient.Connect(ctx)
if err != nil {
golog.Fatal(err)
}
conf.LoadAppConfig("config.yaml")
go web.Start(global.Plugin.Web.Address, WebAssets)
ctl.Start(global.Plugin.Ctl.Address)
}