stats: condensed transfer output to fit 80x25 terminals

This commit is contained in:
ishuah 2017-12-08 11:02:57 +03:00 committed by Ishuah Kariuki
parent 5061aaaf46
commit b05e472d2e

View file

@ -561,7 +561,7 @@ func (acc *Account) ETA() (eta time.Duration, ok bool) {
// String produces stats for this file // String produces stats for this file
func (acc *Account) String() string { func (acc *Account) String() string {
a, b := acc.Progress() a, b := acc.Progress()
bps, cur := acc.Speed() _, cur := acc.Speed()
eta, etaok := acc.ETA() eta, etaok := acc.ETA()
etas := "-" etas := "-"
if etaok { if etaok {
@ -572,8 +572,8 @@ func (acc *Account) String() string {
} }
} }
name := []rune(acc.name) name := []rune(acc.name)
if len(name) > 45 { if len(name) > 40 {
where := len(name) - 42 where := len(name) - 37
name = append([]rune{'.', '.', '.'}, name[where:]...) name = append([]rune{'.', '.', '.'}, name[where:]...)
} }
@ -581,17 +581,17 @@ func (acc *Account) String() string {
cur = cur * 8 cur = cur * 8
} }
done := fmt.Sprintf("%2s/%s", SizeSuffix(a), SizeSuffix(b)) percentageDone := 0
if b > 0 { if b > 0 {
done += fmt.Sprintf(" %2d%% done, ", int(100*float64(a)/float64(b))) percentageDone = int(100 * float64(a) / float64(b))
} else {
done += " 0%% done, "
} }
return fmt.Sprintf("%45s: %s%s / %s, ETA: %s",
done := fmt.Sprintf("%2d%% /%s", percentageDone, SizeSuffix(b))
return fmt.Sprintf("%45s: %s, %s/s, %s",
string(name), string(name),
done, done,
SizeSuffix(bps).Unit(strings.Title(Config.DataRateUnit)+"/s"), SizeSuffix(cur),
SizeSuffix(cur).Unit(strings.Title(Config.DataRateUnit)+"/s"),
etas, etas,
) )
} }