From 1340ab73f41fa50dd46bca4d6e149cbc994bd6cf Mon Sep 17 00:00:00 2001 From: tuvia-akeyless Date: Sun, 4 Feb 2024 10:43:09 +0200 Subject: [PATCH] done --- command.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index 9d46884..f8c5c64 100644 --- a/command.go +++ b/command.go @@ -526,6 +526,8 @@ func (cmd *Command) ChildrenDescriptions(prefix, indent string) string { } } format := fmt.Sprintf("%s%%-%ds%s%%s%%s\n", prefix, length, indent) + + var childrenList []string for _, child := range cmd.children { if child.Hidden { continue @@ -538,7 +540,15 @@ func (cmd *Command) ChildrenDescriptions(prefix, indent string) string { aliasesBuff.WriteString(")") aliases = aliasesBuff.String() } - fmt.Fprintf(buff, format, child.Name, child.Desc, aliases) + + childStr := fmt.Sprintf(format, child.Name, child.Desc, aliases) + childrenList = append(childrenList, childStr) + } + + sort.Strings(childrenList) + + for _, line := range childrenList { + fmt.Fprint(buff, line) } return buff.String() }