3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-02-13 04:00:48 +01:00

refactor service help sorting

This commit is contained in:
Shivaram Lingamneni 2025-02-05 00:47:23 -05:00
parent a850602bcc
commit e1b5a05c27

View File

@ -7,7 +7,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"log" "log"
"sort" "slices"
"strings" "strings"
"time" "time"
@ -250,7 +250,7 @@ func serviceHelpHandler(service *ircService, server *Server, client *Client, par
client.t("Here are the commands you can use:"), client.t("Here are the commands you can use:"),
}...) }...)
// show general help // show general help
var shownHelpLines sort.StringSlice var shownHelpLines []string
var disabledCommands bool var disabledCommands bool
for _, commandInfo := range service.Commands { for _, commandInfo := range service.Commands {
// skip commands user can't access // skip commands user can't access
@ -268,13 +268,13 @@ func serviceHelpHandler(service *ircService, server *Server, client *Client, par
shownHelpLines = append(shownHelpLines, " "+ircfmt.Unescape(client.t(commandInfo.helpShort))) shownHelpLines = append(shownHelpLines, " "+ircfmt.Unescape(client.t(commandInfo.helpShort)))
} }
// sort help lines
slices.Sort(shownHelpLines)
if disabledCommands { if disabledCommands {
shownHelpLines = append(shownHelpLines, " "+client.t("... and other commands which have been disabled")) shownHelpLines = append(shownHelpLines, " "+client.t("... and other commands which have been disabled"))
} }
// sort help lines
sort.Sort(shownHelpLines)
// push out help text // push out help text
for _, line := range helpBannerLines { for _, line := range helpBannerLines {
sendNotice(line) sendNotice(line)