Changeset 339 in code for trunk


Ignore:
Timestamp:
Jun 24, 2020, 10:08:35 AM (5 years ago)
Author:
contact
Message:

service: list commands in lexicographic order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/service.go

    r335 r339  
    1818        "io/ioutil"
    1919        "math/big"
     20        "sort"
    2021        "strings"
    2122        "time"
     
    124125        }
    125126        return cmd.children.Get(params)
     127}
     128
     129func (cmds serviceCommandSet) Names() []string {
     130        l := make([]string, 0, len(cmds))
     131        for name := range cmds {
     132                l = append(l, name)
     133        }
     134        sort.Strings(l)
     135        return l
    126136}
    127137
     
    197207
    198208func appendServiceCommandSetHelp(cmds serviceCommandSet, prefix []string, admin bool, l *[]string) {
    199         for name, cmd := range cmds {
     209        for _, name := range cmds.Names() {
     210                cmd := cmds[name]
    200211                if cmd.admin && !admin {
    201212                        continue
Note: See TracChangeset for help on using the changeset viewer.