Reorder items in generated source files.

Ideally they would always have been sorted as such, but this seems more
critical in migrating from one service definition to another where the ordering might
change.
This commit is contained in:
John Beisley committed 2022-03-13 09:02:29 +00:00
1 parent 730ab6506b
commit ca81a64b42
8 files changed
+11755 -11715

No files matched your search

+9
View File
@@ -2,6 +2,7 @@ package scpd
import (
"encoding/xml"
"sort"
"strings"
)
@@ -37,6 +38,14 @@ func (scpd *SCPD) Clean() {
}
}
func (scpd *SCPD) OrderedActions() []Action {
actions := append([]Action{}, scpd.Actions...)
sort.SliceStable(actions, func(i, j int) bool {
return actions[i].Name < actions[j].Name
})
return actions
}
func (scpd *SCPD) GetStateVariable(variable string) *StateVariable {
for i := range scpd.StateVariables {
v := &scpd.StateVariables[i]