feat(commands): sort /help output alphabetically
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ed1d5ec4ea
commit
a2bb4c7704
1 changed files with 7 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ package commands
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -28,8 +29,12 @@ func formatHelpMessage(defs []Definition) string {
|
|||
return "No commands available."
|
||||
}
|
||||
|
||||
lines := make([]string, 0, len(defs))
|
||||
for _, def := range defs {
|
||||
sorted := make([]Definition, len(defs))
|
||||
copy(sorted, defs)
|
||||
sort.Slice(sorted, func(i, j int) bool { return sorted[i].Name < sorted[j].Name })
|
||||
|
||||
lines := make([]string, 0, len(sorted))
|
||||
for _, def := range sorted {
|
||||
usage := def.EffectiveUsage()
|
||||
if usage == "" {
|
||||
usage = "/" + def.Name
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue