diff --git a/main.go b/main.go index 722ae12..b823aeb 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,8 @@ import ( "github.com/logrusorgru/aurora" "github.com/syndtr/goleveldb/leveldb" + terminal "github.com/wayneashleyberry/terminal-dimensions" + InternalUtils "./internals/" ESI "./client" @@ -622,6 +624,12 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string { } 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 { expirationDate := time.Time(*order.Issued).Add(time.Duration(*order.Duration) * time.Hour * 24) 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) } - 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, pinNames[*order.TypeID], ac.FormatMoney(*order.Price), @@ -666,6 +674,8 @@ func printCharacterMarketOrders(swaggerclient *ESI.App, m *Character) string { quantity, sInfo.Name, ) + + content = content + fmt.Sprintf(lineFormat, line) } return content