Truncate orders lines to fit in the terminal
This commit is contained in:
parent
44fb43a8e9
commit
107ab2522f
1 changed files with 11 additions and 1 deletions
12
main.go
12
main.go
|
@ -23,6 +23,8 @@ import (
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
|
|
||||||
|
terminal "github.com/wayneashleyberry/terminal-dimensions"
|
||||||
|
|
||||||
InternalUtils "./internals/"
|
InternalUtils "./internals/"
|
||||||
|
|
||||||
ESI "./client"
|
ESI "./client"
|
||||||
|
@ -622,6 +624,12 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
}
|
}
|
||||||
pinNames := getUniverseNames(swaggerclient, &ptIds)
|
pinNames := getUniverseNames(swaggerclient, &ptIds)
|
||||||
|
|
||||||
|
maxWidth, _ := terminal.Width()
|
||||||
|
// We need to add the length of the colors
|
||||||
|
maxWidth = maxWidth + uint(len(fmt.Sprint(aurora.Red("")))*2)
|
||||||
|
|
||||||
|
lineFormat := fmt.Sprintf("%%.%ds\n", maxWidth)
|
||||||
|
|
||||||
for _, order := range orders {
|
for _, order := range orders {
|
||||||
expirationDate := time.Time(*order.Issued).Add(time.Duration(*order.Duration) * time.Hour * 24)
|
expirationDate := time.Time(*order.Issued).Add(time.Duration(*order.Duration) * time.Hour * 24)
|
||||||
remainingAmount := *order.Price * float32(*order.VolumeRemain)
|
remainingAmount := *order.Price * float32(*order.VolumeRemain)
|
||||||
|
@ -658,7 +666,7 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
log.Fatalf("Got error on getStructureStationInfo: %T %s", sErr, sErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
content = content + fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) %s\n",
|
line := fmt.Sprintf(" %s % 25.25s ISK % 12s ISK % 13s (%s) %s",
|
||||||
status,
|
status,
|
||||||
pinNames[*order.TypeID],
|
pinNames[*order.TypeID],
|
||||||
ac.FormatMoney(*order.Price),
|
ac.FormatMoney(*order.Price),
|
||||||
|
@ -666,6 +674,8 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string {
|
||||||
quantity,
|
quantity,
|
||||||
sInfo.Name,
|
sInfo.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
content = content + fmt.Sprintf(lineFormat, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
Reference in a new issue