From 456099591a92fe63d05ce01fa3144dc8bbd7ba31 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:27:11 +0300 Subject: [PATCH] Sort commands also in the "subcommands" section --- CliFx/Formatting/HelpConsoleFormatter.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CliFx/Formatting/HelpConsoleFormatter.cs b/CliFx/Formatting/HelpConsoleFormatter.cs index bec4fb9..3b51f96 100644 --- a/CliFx/Formatting/HelpConsoleFormatter.cs +++ b/CliFx/Formatting/HelpConsoleFormatter.cs @@ -206,7 +206,7 @@ internal class HelpConsoleFormatter : ConsoleFormatter Write('.'); Write(' '); } - + // Default value if (!parameterSchema.IsRequired) { @@ -368,7 +368,8 @@ internal class HelpConsoleFormatter : ConsoleFormatter var childCommandSchemas = _context .ApplicationSchema .GetChildCommands(_context.CommandSchema.Name) - .OrderBy(a => a.Name, StringComparer.Ordinal); + .OrderBy(a => a.Name, StringComparer.Ordinal) + .ToArray(); if (!childCommandSchemas.Any()) return; @@ -403,7 +404,9 @@ internal class HelpConsoleFormatter : ConsoleFormatter // Child commands of child command var grandChildCommandSchemas = _context .ApplicationSchema - .GetChildCommands(childCommandSchema.Name); + .GetChildCommands(childCommandSchema.Name) + .OrderBy(c => c.Name, StringComparer.Ordinal) + .ToArray(); if (grandChildCommandSchemas.Any()) {