-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (39 loc) · 880 Bytes
/
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
package main
import (
"flag"
"fmt"
"sorted-awesome-go/internal/awesomego"
"sorted-awesome-go/pkg/cache"
"sorted-awesome-go/pkg/github"
"sorted-awesome-go/pkg/writer"
)
const (
templateFile = "./template/index.html"
htmlOutputFile = "./index.html"
)
var flushCache bool
func main() {
flag.BoolVar(&flushCache, "flush", false, "flush cache")
flag.Parse()
localCache, err := cache.NewLocalCache()
if err != nil {
panic(err)
}
if flushCache {
err := localCache.EraseAll()
if err != nil {
panic(err)
}
}
githubClient := github.NewClient(localCache)
awesomeGoReader := awesomego.NewReader(localCache, githubClient)
result, err := awesomeGoReader.Read()
if err != nil {
panic(err)
}
err = writer.WriteHTMLFile(htmlOutputFile, templateFile, result)
if err != nil {
panic(err)
}
fmt.Printf("🦄 Wrote output to %q\n", htmlOutputFile)
}