Skip to content

Commit 2bc26fc

Browse files
committed
fix: sort commands before printing
Resolves #855.
1 parent 98dcd36 commit 2bc26fc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/vale/info.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"slices"
67

78
"github.com/olekukonko/tablewriter"
89
"github.com/pterm/pterm"
910
"github.com/spf13/pflag"
11+
"golang.org/x/exp/maps"
1012

1113
"github.com/errata-ai/vale/v3/internal/core"
1214
)
@@ -105,10 +107,13 @@ func init() {
105107
table.Render()
106108
table.ClearRows()
107109

110+
commandKeys := maps.Keys(commandInfo)
111+
slices.Sort(commandKeys)
112+
108113
fmt.Println(pterm.Bold.Sprintf("Commands:"))
109-
for cmd, use := range commandInfo {
114+
for _, cmd := range commandKeys {
110115
if !core.StringInSlice(cmd, hidden) {
111-
table.Append([]string{toCodeStyle(cmd), use})
116+
table.Append([]string{toCodeStyle(cmd), commandInfo[cmd]})
112117
}
113118
}
114119
table.Render()

0 commit comments

Comments
 (0)