-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommands.go
85 lines (69 loc) · 1.38 KB
/
commands.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
package main
import (
"git.blob42.xyz/blob42/hugobot/v3/export"
"git.blob42.xyz/blob42/hugobot/v3/feeds"
"git.blob42.xyz/blob42/hugobot/v3/static"
"log"
cli "gopkg.in/urfave/cli.v1"
)
var startServerCmd = cli.Command{
Name: "server",
Aliases: []string{"s"},
Usage: "Run server",
Action: startServer,
}
var exportCmdGrp = cli.Command{
Name: "export",
Aliases: []string{"e"},
Usage: "Export to hugo",
Subcommands: []cli.Command{
exportPostsCmd,
exportWeeksCmd,
exportBTCAddressesCmd,
},
}
var exportBTCAddressesCmd = cli.Command{
Name: "btc",
Usage: "export bitcoin addresses",
Action: exportAddresses,
}
var exportWeeksCmd = cli.Command{
Name: "weeks",
Usage: "export weeks",
Action: exportWeeks,
}
var exportPostsCmd = cli.Command{
Name: "posts",
Usage: "Export posts to hugo",
Action: exportPosts,
}
func startServer(c *cli.Context) {
server()
}
func exportPosts(c *cli.Context) {
exporter := export.NewHugoExporter()
feeds, err := feeds.ListFeeds()
if err != nil {
log.Fatal(err)
}
for _, f := range feeds {
exporter.Export(*f)
}
// Export static data
err = static.HugoExportData()
if err != nil {
log.Fatal(err)
}
}
func exportWeeks(c *cli.Context) {
err := export.ExportWeeks()
if err != nil {
log.Fatal(err)
}
}
func exportAddresses(c *cli.Context) {
err := export.ExportBTCAddresses()
if err != nil {
log.Fatal(err)
}
}