-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.go
72 lines (55 loc) · 1.25 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
63
64
65
66
67
68
69
70
71
72
package main
import (
"os"
"github.com/ubavic/bas-celik/document"
"github.com/ubavic/bas-celik/internal"
"github.com/ubavic/bas-celik/internal/logger"
"embed"
"fmt"
)
//go:embed assets/version
var version string
//go:embed embed/*
var embedFS embed.FS
func main() {
internal.SetVersion(version)
cfg, exit := internal.ProcessFlags()
if exit {
return
}
if !cfg.Verbose {
logger.DisableLog()
}
cfg.EmbedDirectory = embedFS
err := configDocumentPackage()
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
err = internal.Run(cfg)
if err != nil {
fmt.Println("Error:", err)
os.Exit(2)
}
}
func configDocumentPackage() error {
documentConfig := document.DocumentConfig{}
var err error
documentConfig.FontRegular, err = embedFS.ReadFile("embed/liberationSansRegular.ttf")
if err != nil {
return fmt.Errorf("reading font: %w", err)
}
documentConfig.FontBold, err = embedFS.ReadFile("embed/liberationSansBold.ttf")
if err != nil {
return fmt.Errorf("reading font: %w", err)
}
documentConfig.RfzoLogo, err = embedFS.ReadFile("embed/rfzo.png")
if err != nil {
return fmt.Errorf("reading font: %w", err)
}
err = document.Configure(documentConfig)
if err != nil {
return fmt.Errorf("setup error: %w", err)
}
return nil
}