-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
110 lines (97 loc) · 3.01 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package main
import (
"bytes"
_ "embed"
"github.com/beauxarts/fedorov/cli"
"github.com/beauxarts/fedorov/clo_delegates"
"github.com/beauxarts/fedorov/data"
"github.com/boggydigital/clo"
"github.com/boggydigital/nod"
"github.com/boggydigital/pathways"
"os"
)
const (
dirsOverrideFilename = "directories.txt"
)
var (
//go:embed "cli-commands.txt"
cliCommands []byte
//go:embed "cli-help.txt"
cliHelp []byte
)
func main() {
nod.EnableStdOutPresenter()
ns := nod.NewProgress("fedorov is serving your DRM-free books")
defer ns.End()
if err := pathways.Setup(
dirsOverrideFilename,
data.DefaultFedorovRootDir,
data.RelToAbsDirs,
data.AllAbsDirs...); err != nil {
_ = ns.EndWithError(err)
os.Exit(1)
}
defs, err := clo.Load(
bytes.NewBuffer(cliCommands),
bytes.NewBuffer(cliHelp),
clo_delegates.Values)
if err != nil {
_ = ns.EndWithError(err)
os.Exit(1)
}
clo.HandleFuncs(map[string]clo.Handler{
"backup": cli.BackupHandler,
"cascade": cli.CascadeHandler,
"dehydrate": cli.DehydrateHandler,
"download-litres-books": cli.DownloadLitResBooksHandler,
"download-litres-covers": cli.DownloadLitResCoversHandler,
"get-litres-arts": cli.GetLitResArtsHandler,
"get-litres-authors": cli.GetLitResAuthorsHandler,
"get-litres-contents": cli.GetLitResContentsHandler,
"get-litres-operations": cli.GetLitResOperationsHandler,
"get-litres-series": cli.GetLitResSeriesHandler,
"get-recent-arts": cli.GetRecentArtsHandler,
"get-recent-persons": cli.GetRecentPersonsHandler,
"get-recent-series": cli.GetRecentSeriesHandler,
"get-session-id": cli.GetSessionIdHandler,
"get-videos-metadata": cli.GetVideosMetadataHandler,
"has-arts": cli.HasArtsHandler,
"migrate": cli.MigrateHandler,
"reduce-litres-arts-details": cli.ReduceLitResArtsDetailsHandler,
"reduce-litres-operations": cli.ReduceLitResOperationsHandler,
"serve": cli.ServeHandler,
"sync": cli.SyncHandler,
"version": cli.VersionHandler,
})
if err := defs.AssertCommandsHaveHandlers(); err != nil {
_ = ns.EndWithError(err)
os.Exit(1)
}
//for _, id := range rdx.Keys(data.GenresIdsProperty) {
//
// if genres, ok := rdx.GetAllValues(data.GenresIdsProperty, id); ok {
// fmt.Print(id)
// for _, genre := range genres {
// if genreName, sure := rdx.GetLastVal(data.GenreNameProperty, genre); sure {
// fmt.Print(genreName)
// }
// }
// fmt.Println()
// }
//}
//uniqueRoles := make(map[string]int)
//
//for _, id := range rdx.Keys(data.PersonsRolesProperty) {
// if roles, ok := rdx.GetAllValues(data.PersonsRolesProperty, id); ok {
// for _, role := range roles {
// uniqueRoles[role] = uniqueRoles[role] + 1
// }
// }
//}
//
//fmt.Println(uniqueRoles)
if err := defs.Serve(os.Args[1:]); err != nil {
_ = ns.EndWithError(err)
os.Exit(1)
}
}