-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
43 lines (36 loc) · 719 Bytes
/
cmd.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
package internal
import (
"encoding/json"
"log"
"sync"
)
type generateBlog struct {
repo string
token string
config conf
wg *sync.WaitGroup
}
func newBlog(repo, token string, configfile []byte) *generateBlog {
var config conf
if err := json.Unmarshal(configfile, &config); err != nil {
log.Fatal(err)
}
return &generateBlog{
repo: repo,
token: token,
wg: new(sync.WaitGroup),
config: config,
}
}
// Run fetch issues and generate blog
func Run(repo, token string, configfile []byte) {
g := newBlog(repo, token, configfile)
issues, err := g.getAllIssues()
if err != nil {
log.Fatal(err)
}
g.wg.Add(len(issues))
g.saveArticle(issues)
g.saveReadme(issues)
g.wg.Wait()
}