-
Notifications
You must be signed in to change notification settings - Fork 145
/
check.go
65 lines (56 loc) · 1.27 KB
/
check.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
package main
import (
"fmt"
"log"
"strings"
"github.com/urfave/cli"
)
var check = cli.Command{
Name: "check",
Usage: "检查缓存文件",
Aliases: []string{"c", "chk"},
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
if err := initLoadStore(c); err != nil {
return err
}
fmt.Printf("书名: %#v\n", chapter.BookName)
fmt.Printf("作者: %#v\n", chapter.Author)
fmt.Printf("封面: %s\n", chapter.CoverURL)
fmt.Printf("简介: \n\t%v\n", strings.Replace(chapter.Description, "\n", "\n\t", -1))
fmt.Printf("章节数: \n")
for _, v := range chapter.Volumes {
var VIP string
if v.IsVIP {
VIP = "VIP"
} else {
VIP = "免费"
}
fmt.Printf("\t%s卷(%s) %d章\n", v.Name, VIP, len(v.Chapters))
}
var (
chCount = 0
isDone = 0
isExample = 0
isDonwExample = 0
)
for _, v := range chapter.Volumes {
chCount += len(v.Chapters)
for _, v2 := range v.Chapters {
if len(v2.Text) != 0 {
isDone++
}
if len(v2.Example) != 0 {
isExample++
}
if (len(v2.Example) != 0) && (len(v2.Text) != 0) {
isDonwExample++
}
}
}
if isDone != 0 {
log.Printf("[读入] 已缓存:%d 样本:%d 完成样本:%d", isDone, isExample, isDonwExample)
}
return nil
},
}