-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (51 loc) · 1.19 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
package main
import (
"fmt"
"os"
"scan2epub/commands"
"scan2epub/config"
"scan2epub/lang"
"scan2epub/utils"
cli "github.com/urfave/cli/v2"
ini "gopkg.in/ini.v1"
)
func main() {
if err := config.InitConfig(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
log, err := utils.GetLog()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
defer log.Close()
config.CONFIG_INI, err = ini.Load(config.CONFIG_FILE)
if err != nil {
log.PrintfErr("%v\n", err)
os.Exit(1)
}
if err := config.InitEpubDir(); err != nil {
log.PrintfErr("%v\n", err)
os.Exit(1)
}
l := lang.GetLocalize()
l.SetLang(os.Getenv("LANG"))
l.AddStrings(&lang.EN_STRINGS, "en_US.UTF-8", "en_GB.UTF-8", "en")
l.AddStrings(&lang.FR_STRINGS, "fr_FR.UTF-8", "fr_CA.UTF-8", "fr")
app := cli.NewApp()
app.Name = config.NAME
app.Usage = l.Get("usage")
app.Version = config.VERSION
app.Action = commands.MainAction
app.Flags = commands.MainFlags()
app.Commands = []*cli.Command{
commands.ConvertCommand(),
commands.ExistsCommand(),
commands.IntervalCommand(),
}
if err := app.Run(os.Args); err != nil {
log.PrintfErr("%v\n", err)
}
_ = utils.RmTmpDir()
}