Skip to content

Commit 3f779e1

Browse files
authored
Sort output of listing search attributes (#1016)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed Sort output of listing search attributes ## Why? Easier to check the list than viewing a random order of search attributes. ## Checklist <!--- add/delete as needed ---> 1. Closes <!-- add issue number here --> 2. How was this tested: <!--- Please describe how you tested your changes/how we can test them --> 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io -->
1 parent 569da5e commit 3f779e1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/temporalcli/commands.operator_search_attribute.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package temporalcli
22

33
import (
44
"fmt"
5+
"slices"
56
"strings"
67

78
"github.com/fatih/color"
@@ -130,12 +131,17 @@ func (c *TemporalOperatorSearchAttributeListCommand) run(cctx *CommandContext, a
130131
Type: saType.String(),
131132
})
132133
}
134+
slices.SortFunc(sas, func(a, b saNameType) int { return strings.Compare(a.Name, b.Name) })
135+
136+
var csa []saNameType
133137
for saName, saType := range resp.CustomAttributes {
134-
sas = append(sas, saNameType{
138+
csa = append(csa, saNameType{
135139
Name: saName,
136140
Type: saType.String(),
137141
})
138142
}
143+
slices.SortFunc(csa, func(a, b saNameType) int { return strings.Compare(a.Name, b.Name) })
144+
sas = append(sas, csa...)
139145

140146
return cctx.Printer.PrintStructured(sas, printer.StructuredOptions{Table: &printer.TableOptions{}})
141147
}

0 commit comments

Comments
 (0)