Planetary interaction: Colors and cleanup of code

This commit is contained in:
Thomas Schwery 2017-02-06 13:19:06 +01:00
parent 82a88033b3
commit 34190fe98b

35
main.go
View file

@ -18,6 +18,7 @@ import (
"github.com/go-openapi/strfmt"
"github.com/leekchan/accounting"
"github.com/logrusorgru/aurora"
ESI "client"
ESIPlanetaryInteraction "client/planetary_interaction"
@ -238,25 +239,31 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
pesiresponse, pesierr := swaggerclient.PlanetaryInteraction.GetCharactersCharacterIDPlanetsPlanetID(pcallParam, nil)
if pesierr != nil {
fmt.Println("Error while getting the planetary interaction information")
log.Fatalf("Error on CharactersCharacterIDPlanetsPlanetID: %s", pesierr)
fmt.Println(" Error while getting the planetary interaction information")
log.Printf("Error on CharactersCharacterIDPlanetsPlanetID: %s\n", pesierr)
continue
}
for _, pin := range pesiresponse.Payload.Pins {
if pin.ExtractorDetails != nil {
status := "✘"
if time.Time(pin.ExpiryTime).After(time.Now()) {
status = "✔"
status := fmt.Sprint(aurora.Red("✘").Bold())
statuscomment := fmt.Sprint(aurora.Red("expired").Bold())
duration := now.Sub(time.Time(pin.ExpiryTime))
if time.Time(pin.ExpiryTime).After(now) {
status = fmt.Sprint(aurora.Green("✔").Bold())
statuscomment = "expires"
duration = time.Time(pin.ExpiryTime).Sub(now)
}
duration := time.Time(pin.ExpiryTime).Sub(now)
fmt.Printf(" %s Extractor % 5ds cycle, % 6d per cycle, expires %s (%02d:%02d)\n",
fmt.Printf(" %s Extractor % 5ds cycle, % 6d per cycle, %s %s (%02dd%02d:%02d)\n",
status,
*pin.ExtractorDetails.CycleTime,
*pin.ExtractorDetails.QtyPerCycle,
statuscomment,
time.Time(pin.ExpiryTime).Format("_2 Jan 2006, 15:04"),
int32(duration.Minutes())/60,
int32(duration.Minutes())%60,
(int32(duration.Minutes()) / (60 * 24)),
(int32(duration.Minutes())/60)%24,
(int32(duration.Minutes()) % 60),
)
} else if pin.SchematicID != 0 {
@ -267,14 +274,6 @@ func printCharacterPlanets(swaggerclient *ESI.App, m *Character) {
schematicInfo.CycleTime,
schematicInfo.SchematicName,
)
} else {
/*
fmt.Printf(" %d %d (%s)\n%v\n",
*pin.TypeID,
*pin.PinID,
pin.LastCycleStart,
pin)
*/
}
}
}