Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cmd

import (
"cmp"
"fmt"
"slices"
"sort"
"strings"

Expand Down Expand Up @@ -61,15 +63,14 @@ func PrintHelpMessage(cmd *cobra.Command) error {
}

func maxCommandNameLen(cmd *cobra.Command) int {
maxLen := 0

for _, c := range cmd.Commands() {
if l := len(c.Name()); l > maxLen {
maxLen = l
}
commands := cmd.Commands()
if len(commands) == 0 {
return 0
}

return maxLen
maxCmd := slices.MaxFunc(commands, func(a, b *cobra.Command) int {
return cmp.Compare(len(a.Name()), len(b.Name()))
})
return len(maxCmd.Name())
}

func rpad(s string, padding int) string {
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ title: Changelog

## [Unreleased](https://github.com/lets-cli/lets/releases/tag/v0.0.X)

* `[Fixed]` Fixed indentation issues for long commands in help output. Command names are now properly padded for consistent alignment.

## [0.0.58](https://github.com/lets-cli/lets/releases/tag/v0.0.58)

* `[Added]` `group` directive for commands. Organize commands into groups for better readability in help output. See [config reference for group](/docs/config#group).
Expand Down