Skip to content

Commit

Permalink
Merge pull request #1520 from hashicorp/f-sort-tg-names-summaries
Browse files Browse the repository at this point in the history
Sorting the job summaries while displaying
  • Loading branch information
diptanu authored Aug 4, 2016
2 parents 0b02b7a + 4cc24c0 commit b140b03
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions command/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/gob"
"fmt"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -257,14 +258,18 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
if summary != nil {
summaries := make([]string, len(summary.Summary)+1)
summaries[0] = "Task Group|Queued|Starting|Running|Failed|Complete|Lost"
idx := 1
for tg, tgs := range summary.Summary {
summaries[idx] = fmt.Sprintf("%s|%d|%d|%d|%d|%d|%d",
tg, tgs.Queued, tgs.Starting,
taskGroups := make([]string, 0, len(summary.Summary))
for taskGroup := range summary.Summary {
taskGroups = append(taskGroups, taskGroup)
}
sort.Strings(taskGroups)
for idx, taskGroup := range taskGroups {
tgs := summary.Summary[taskGroup]
summaries[idx+1] = fmt.Sprintf("%s|%d|%d|%d|%d|%d|%d",
taskGroup, tgs.Queued, tgs.Starting,
tgs.Running, tgs.Failed,
tgs.Complete, tgs.Lost,
)
idx += 1
}
c.Ui.Output(formatList(summaries))
}
Expand Down

0 comments on commit b140b03

Please sign in to comment.