Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Arranged metrics for pulsectl metric list in alphabetical order
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanyfay committed Oct 21, 2015
1 parent 89b000d commit f282f24
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/pulsectl/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main
import (
"fmt"
"os"
"sort"
"strconv"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -61,9 +62,16 @@ func listMetrics(ctx *cli.Context) {
for _, mt := range mts.Catalog {
metsByVer[mt.Namespace] = append(metsByVer[mt.Namespace], strconv.Itoa(mt.Version))
}
//make list in alphabetical order
var key []string
for k := range metsByVer {
key = append(key, k)
}
sort.Strings(key)

printFields(w, false, 0, "NAMESPACE", "VERSIONS")
for ns, vers := range metsByVer {
printFields(w, false, 0, ns, strings.Join(vers, ","))
for _, ns := range key {
printFields(w, false, 0, ns, strings.Join(metsByVer[ns], ","))
}
w.Flush()
return
Expand Down

0 comments on commit f282f24

Please sign in to comment.