Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat: modify bool format
Browse files Browse the repository at this point in the history
  • Loading branch information
yeqown committed Feb 8, 2022
1 parent d11d0b6 commit 48ff02d
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions internal/render_termui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
_ "image/jpeg"
_ "image/png"
"os"
"strconv"

ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
Expand Down Expand Up @@ -169,15 +168,7 @@ func (t termuiRenderer) renderingResult(results []*synchronizeResult) {
}

for idx, r := range results {
row := []string{
string(r.mode),
r.key,
strconv.FormatBool(r.succeeded),
strconv.FormatBool(r.published),
r.error,
}
tb.Rows = append(tb.Rows, row)

tb.Rows = append(tb.Rows, t.renderResultSingle(r))
tb.RowStyles[idx+1] = ui.NewStyle(ui.ColorGreen)
if !r.succeeded {
tb.RowStyles[idx+1] = ui.NewStyle(ui.ColorRed, ui.ColorBlack, ui.ModifierBold)
Expand All @@ -188,3 +179,20 @@ func (t termuiRenderer) renderingResult(results []*synchronizeResult) {
ui.Render(tb)
_ = t.wait()
}

func (t termuiRenderer) renderResultSingle(r *synchronizeResult) []string {
formatBool := func(b bool) string {
if b {
return "O"
}
return "F"
}

return []string{
string(r.mode),
r.key,
formatBool(r.succeeded),
formatBool(r.published),
r.error,
}
}

0 comments on commit 48ff02d

Please sign in to comment.