Skip to content

Commit

Permalink
Merge pull request #8 from TheDevMinerTV/fix/report-rendering
Browse files Browse the repository at this point in the history
fix: report rendering
  • Loading branch information
TheDevMinerTV authored Jul 9, 2024
2 parents a222310 + 8ca47f5 commit 06865bd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ func printReport(
estTrafficNextWeekFmt := humanize.BigBytes(estTrafficNextWeek)

estTrafficChange := big.NewInt(0).Sub(oldTrafficLastWeek, estTrafficNextWeek)
estTrafficChangeFmt := humanize.BigBytes(estTrafficChange)
estTrafficChangeFmt := ""
if estTrafficChange.Cmp(big.NewInt(0)) == 0 {
estTrafficChangeFmt = indicatorColor.Sprint(estTrafficChangeFmt)
estTrafficChangeFmt = "No change"
} else if estTrafficChange.Cmp(big.NewInt(0)) > 0 {
estTrafficChange.Mul(estTrafficChange, big.NewInt(-1))
estTrafficChangeFmt = indicatorColor.Sprintf("%s saved", estTrafficChangeFmt)
estTrafficChangeFmt = "%s saved"
} else {
estTrafficChangeFmt = indicatorColor.Sprintf("%s wasted", estTrafficChangeFmt)
estTrafficChange.Mul(estTrafficChange, big.NewInt(-1))
estTrafficChangeFmt = "%s wasted"
}
estTrafficChangeFmt = indicatorColor.Sprintf(estTrafficChangeFmt, humanize.BigBytes(estTrafficChange))

fmt.Println()
fmt.Printf(
Expand All @@ -165,6 +166,8 @@ func printReport(
}

func grayParens(s string, args ...any) string {
f := fmt.Sprintf("(%s)", s)
return gray.Sprintf(f, args...)
a := gray.Sprint("(")
b := gray.Sprint(")")

return fmt.Sprintf("%s%s%s", a, fmt.Sprintf(s, args...), b)
}

0 comments on commit 06865bd

Please sign in to comment.