Skip to content

Commit 25ad348

Browse files
committed
Add changelog entry for slices for max cmd name
1 parent f4d982d commit 25ad348

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

cmd/root.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ func PrintHelpMessage(cmd *cobra.Command) error {
6363
}
6464

6565
func maxCommandNameLen(cmd *cobra.Command) int {
66-
maxCmd := slices.MaxFunc(cmd.Commands(), func(a, b *cobra.Command) int {
66+
commands := cmd.Commands()
67+
if len(commands) == 0 {
68+
return 0
69+
}
70+
maxCmd := slices.MaxFunc(commands, func(a, b *cobra.Command) int {
6771
return cmp.Compare(len(a.Name()), len(b.Name()))
6872
})
6973
return len(maxCmd.Name())

docs/docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Changelog
55

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

8+
* `[Fixed]` Fixed indentation issues for long commands in help output. Command names are now properly padded for consistent alignment.
9+
810
## [0.0.58](https://github.com/lets-cli/lets/releases/tag/v0.0.58)
911

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

0 commit comments

Comments
 (0)