Skip to content

Commit

Permalink
Print summary after application exits
Browse files Browse the repository at this point in the history
  • Loading branch information
mkchoi212 committed Dec 29, 2017
1 parent f617cdb commit cc25b6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func main() {
log.Panicln("No conflicts found")
}
conflictCount = len(conflicts)
fmt.Println("Good-bye!")

printSummary()

g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions summary.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"fmt"

"github.com/jroimartin/gocui"
Expand All @@ -18,3 +19,29 @@ func printHelp(v *gocui.View) {
`
fmt.Fprintf(v, Colorize(instruction, Purple))
}

func printSummary() {
resolvedCnt := 0
var line string

for _, c := range conflicts {
if c.Resolved {
line = Colorize(fmt.Sprintf("✔ %s: %d", c.FileName, c.Start), Green)
resolvedCnt++
} else {
line = Colorize(fmt.Sprintf("✘ %s: %d", c.FileName, c.Start), Red)
}
fmt.Println(line)
}

var buf bytes.Buffer
if resolvedCnt != len(conflicts) {
buf.WriteString("\nResolved ")
buf.WriteString(ColorizeLight(fmt.Sprintf("%d ", resolvedCnt), Red))
buf.WriteString("conflict(s) out of ")
buf.WriteString(ColorizeLight(fmt.Sprintf("%d", len(conflicts)), Red))
} else {
buf.WriteString(Colorize(fmt.Sprintf("\nFixed All Conflicts 🎉"), Green))
}
fmt.Println(buf.String())
}

0 comments on commit cc25b6d

Please sign in to comment.