|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
humanize "github.com/dustin/go-humanize"
|
|
|
|
humanize "github.com/dustin/go-humanize"
|
|
|
|
apitypes "github.com/miguelmota/cointop/pkg/api/types"
|
|
|
|
apitypes "github.com/miguelmota/cointop/pkg/api/types"
|
|
|
|
"github.com/miguelmota/cointop/pkg/color"
|
|
|
|
"github.com/miguelmota/cointop/pkg/color"
|
|
|
|
"github.com/miguelmota/cointop/pkg/pad"
|
|
|
|
|
|
|
|
"github.com/miguelmota/cointop/pkg/table"
|
|
|
|
"github.com/miguelmota/cointop/pkg/table"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -58,21 +57,21 @@ func (ct *Cointop) updateTable() error {
|
|
|
|
lastchar := len(name)
|
|
|
|
lastchar := len(name)
|
|
|
|
if lastchar > 20 {
|
|
|
|
if lastchar > 20 {
|
|
|
|
lastchar = 20
|
|
|
|
lastchar = 20
|
|
|
|
name = fmt.Sprintf("%s...", name[0:17])
|
|
|
|
name = fmt.Sprintf("%s...", name[0:18])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ct.table.AddRow(
|
|
|
|
ct.table.AddRow(
|
|
|
|
pad.Left(fmt.Sprint(coin.Rank), 4, " "),
|
|
|
|
fmt.Sprintf("%6v ", coin.Rank),
|
|
|
|
pad.Right(" "+string(name), 22, " "),
|
|
|
|
fmt.Sprintf("%.22s", name),
|
|
|
|
pad.Right(coin.Symbol, 6, " "),
|
|
|
|
fmt.Sprintf("%.6s", coin.Symbol),
|
|
|
|
colorprice(pad.Left(humanize.Commaf(coin.PriceUSD), 12, " ")),
|
|
|
|
colorprice(fmt.Sprintf("%12s", humanize.Commaf(coin.PriceUSD))),
|
|
|
|
pad.Left(humanize.Commaf(coin.MarketCapUSD), 17, " "),
|
|
|
|
fmt.Sprintf("%17s", humanize.Commaf(coin.MarketCapUSD)),
|
|
|
|
pad.Left(humanize.Commaf(coin.USD24HVolume), 15, " "),
|
|
|
|
fmt.Sprintf("%15s", humanize.Commaf(coin.USD24HVolume)),
|
|
|
|
color1h(pad.Left(fmt.Sprintf("%.2f%%", coin.PercentChange1H), 9, " ")),
|
|
|
|
color1h(fmt.Sprintf("%8.2f%%", coin.PercentChange1H)),
|
|
|
|
color24h(pad.Left(fmt.Sprintf("%.2f%%", coin.PercentChange24H), 9, " ")),
|
|
|
|
color24h(fmt.Sprintf("%8.2f%%", coin.PercentChange24H)),
|
|
|
|
color7d(pad.Left(fmt.Sprintf("%.2f%%", coin.PercentChange7D), 9, " ")),
|
|
|
|
color7d(fmt.Sprintf("%8.2f%%", coin.PercentChange7D)),
|
|
|
|
pad.Left(humanize.Commaf(coin.TotalSupply), 20, " "),
|
|
|
|
fmt.Sprintf("%20s", humanize.Commaf(coin.TotalSupply)),
|
|
|
|
pad.Left(humanize.Commaf(coin.AvailableSupply), 18, " "),
|
|
|
|
fmt.Sprintf("%18s", humanize.Commaf(coin.AvailableSupply)),
|
|
|
|
pad.Left(fmt.Sprintf("%s", lastUpdated), 18, " "),
|
|
|
|
fmt.Sprintf("%18s", lastUpdated),
|
|
|
|
// add %percent of cap
|
|
|
|
// add %percent of cap
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|