-
Notifications
You must be signed in to change notification settings - Fork 1
/
plan.go
44 lines (40 loc) · 1.06 KB
/
plan.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
package mdlog
import (
"fmt"
"log"
)
type Plan map[*Post]*Post
func (p Plan) Print() {
if len(p) == 0 {
fmt.Println("local posts is up to date with remote posts")
return
}
log.Println("------- Change List -------")
for remotePost, localPost := range p {
log.Printf("<< Post [%s] >>", remotePost.ID)
if remotePost.Title != localPost.Title {
log.Printf("Title: %s -> %s\n", remotePost.Title, localPost.Title)
}
if remotePost.Content != localPost.Content {
log.Println("Content: (diff is not supported yet)")
}
if len(remotePost.Tags) != len(localPost.Tags) {
log.Printf("Tags: %s -> %s\n", remotePost.Tags, localPost.Tags)
} else {
var neq bool
for i, v := range remotePost.Tags {
if v != localPost.Tags[i] {
neq = true
break
}
}
if neq {
log.Printf("Tags: %s -> %s\n", remotePost.Tags, localPost.Tags)
}
}
if remotePost.Status != localPost.Status {
log.Printf("Status: %s -> %s\n", PostStatusText(remotePost.Status), PostStatusText(localPost.Status))
}
log.Println("---------------------------")
}
}