cscli metrics -> sort table order (#2908)

This commit is contained in:
mmetc 2024-03-20 13:27:28 +01:00 committed by GitHub
parent c76325b91b
commit d9f2a22ee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -272,9 +272,7 @@ func (ms metricStore) Format(out io.Writer, sections []string, formatType string
// if no sections are specified, we want all of them // if no sections are specified, we want all of them
if len(sections) == 0 { if len(sections) == 0 {
for section := range ms { sections = maptools.SortedKeys(ms)
sections = append(sections, section)
}
} }
for _, section := range sections { for _, section := range sections {
@ -283,7 +281,7 @@ func (ms metricStore) Format(out io.Writer, sections []string, formatType string
switch formatType { switch formatType {
case "human": case "human":
for section := range want { for _, section := range maptools.SortedKeys(want) {
want[section].Table(out, noUnit, showEmpty) want[section].Table(out, noUnit, showEmpty)
} }
case "json": case "json":
@ -376,7 +374,7 @@ cscli metrics list`,
} }
// expandAlias returns a list of sections. The input can be a list of sections or alias. // expandAlias returns a list of sections. The input can be a list of sections or alias.
func (cli *cliMetrics) expandSectionGroups(args []string) []string { func (cli *cliMetrics) expandAlias(args []string) []string {
ret := []string{} ret := []string{}
for _, section := range args { for _, section := range args {
@ -422,7 +420,7 @@ cscli metrics show acquisition parsers scenarios stash -o json`,
// Positional args are optional // Positional args are optional
DisableAutoGenTag: true, DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
args = cli.expandSectionGroups(args) args = cli.expandAlias(args)
return cli.show(args, url, noUnit) return cli.show(args, url, noUnit)
}, },
} }