Skip to content

Commit

Permalink
fix: sort commands before printing
Browse files Browse the repository at this point in the history
Resolves #855.
  • Loading branch information
jdkato committed Jul 8, 2024
1 parent 98dcd36 commit 2bc26fc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/vale/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package main
import (
"fmt"
"os"
"slices"

"github.com/olekukonko/tablewriter"
"github.com/pterm/pterm"
"github.com/spf13/pflag"
"golang.org/x/exp/maps"

"github.com/errata-ai/vale/v3/internal/core"
)
Expand Down Expand Up @@ -105,10 +107,13 @@ func init() {
table.Render()
table.ClearRows()

commandKeys := maps.Keys(commandInfo)
slices.Sort(commandKeys)

fmt.Println(pterm.Bold.Sprintf("Commands:"))
for cmd, use := range commandInfo {
for _, cmd := range commandKeys {
if !core.StringInSlice(cmd, hidden) {
table.Append([]string{toCodeStyle(cmd), use})
table.Append([]string{toCodeStyle(cmd), commandInfo[cmd]})
}
}
table.Render()
Expand Down

0 comments on commit 2bc26fc

Please sign in to comment.