fix: fix filtering by type for output
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
cellarspoon 2022-01-02 16:21:22 +01:00
parent 30209de3e2
commit c900cebc30
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410

View File

@ -124,10 +124,18 @@ can take some time.
var ok bool var ok bool
if stats, ok = allStats[app.Server]; !ok { if stats, ok = allStats[app.Server]; !ok {
stats = serverStatus{} stats = serverStatus{}
if appType == "" {
// count server, no filtering
totalServersCount++ totalServersCount++
} }
}
if app.Type == appType || appType == "" { if app.Type == appType || appType == "" {
if appType != "" {
// only count server if matches filter
totalServersCount++
}
appStats := appStatus{} appStats := appStatus{}
stats.appCount++ stats.appCount++
totalAppsCount++ totalAppsCount++
@ -222,6 +230,7 @@ can take some time.
table.Append(tableRow) table.Append(tableRow)
} }
if table.NumLines() > 0 {
table.Render() table.Render()
if status { if status {
@ -237,8 +246,9 @@ can take some time.
} else { } else {
fmt.Println(fmt.Sprintf("server: %s | total apps: %v", app.Server, serverStat.appCount)) fmt.Println(fmt.Sprintf("server: %s | total apps: %v", app.Server, serverStat.appCount))
} }
}
if len(allStats) > 1 { if len(allStats) > 1 && table.NumLines() > 0 {
fmt.Println() // newline separator for multiple servers fmt.Println() // newline separator for multiple servers
} }