From a9dff7a6219596b0b6b85b8520311b69e3460f2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 20:53:11 +0000 Subject: [PATCH 1/4] Initial plan From c09065509531537306c5fa8cf14847ee4f508b94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 21:10:37 +0000 Subject: [PATCH 2/4] Fix help option formatting to use comma-space separator instead of pipe Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- .../CommandLine/CommandLineApplication.cs | 4 +-- .../CommandLine/CommandOption.cs | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Shared/CommandLineUtils/CommandLine/CommandLineApplication.cs b/src/Shared/CommandLineUtils/CommandLine/CommandLineApplication.cs index b4d85ac00008..145ad3335bf5 100644 --- a/src/Shared/CommandLineUtils/CommandLine/CommandLineApplication.cs +++ b/src/Shared/CommandLineUtils/CommandLine/CommandLineApplication.cs @@ -493,11 +493,11 @@ public string GetHelpText(string commandName = null) optionsBuilder.AppendLine(); optionsBuilder.AppendLine("Options:"); - var maxOptLen = options.Max(o => o.Template.Length); + var maxOptLen = options.Max(o => o.GetDisplayText().Length); var outputFormat = string.Format(CultureInfo.InvariantCulture, " {{0, -{0}}}{{1}}", maxOptLen + 2); foreach (var opt in options) { - optionsBuilder.AppendFormat(CultureInfo.InvariantCulture, outputFormat, opt.Template, opt.Description); + optionsBuilder.AppendFormat(CultureInfo.InvariantCulture, outputFormat, opt.GetDisplayText(), opt.Description); optionsBuilder.AppendLine(); } } diff --git a/src/Shared/CommandLineUtils/CommandLine/CommandOption.cs b/src/Shared/CommandLineUtils/CommandLine/CommandOption.cs index 588dd6af12f8..93b3c66854d1 100644 --- a/src/Shared/CommandLineUtils/CommandLine/CommandOption.cs +++ b/src/Shared/CommandLineUtils/CommandLine/CommandOption.cs @@ -100,6 +100,35 @@ public string Value() return HasValue() ? Values[0] : null; } + public string GetDisplayText() + { + var parts = new List(); + + if (!string.IsNullOrEmpty(SymbolName)) + { + parts.Add($"-{SymbolName}"); + } + + if (!string.IsNullOrEmpty(ShortName)) + { + parts.Add($"-{ShortName}"); + } + + if (!string.IsNullOrEmpty(LongName)) + { + parts.Add($"--{LongName}"); + } + + var result = string.Join(", ", parts); + + if (!string.IsNullOrEmpty(ValueName)) + { + result += $" <{ValueName}>"; + } + + return result; + } + private static bool IsEnglishLetter(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); From 014f221cc5398ad05ffd9e76417fb914714abc61 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 21:48:04 +0000 Subject: [PATCH 3/4] Fix test to expect comma-space separator format in help output Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs b/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs index e9a2e6fc6a4e..e349c6d0dce2 100644 --- a/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs +++ b/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs @@ -813,7 +813,7 @@ public void OptionsCanBeInherited() Assert.Throws(() => app.Execute("subcmd", "-b", "B")); - Assert.Contains("-a|--option-a", subcmd.GetHelpText()); + Assert.Contains("-a, --option-a", subcmd.GetHelpText()); } [Fact] From ef566bfd21012a8db812328e19c2884127dc3a92 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 00:53:38 +0000 Subject: [PATCH 4/4] Add test for GetHelpText formatting with all option types Co-authored-by: radical <1472+radical@users.noreply.github.com> --- .../Shared.Tests/CommandLineApplicationTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs b/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs index e349c6d0dce2..0b4773e7cac6 100644 --- a/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs +++ b/src/Shared/test/Shared.Tests/CommandLineApplicationTests.cs @@ -1220,4 +1220,18 @@ public void ThrowExceptionWhenUnmatchedOptionAndTreatUnmatchedOptionsAsArguments Assert.Equal($"Unrecognized option '{firstOption}'", exception.Message); } + + [Fact] + public void GetHelpTextFormatsAllOptionTypes() + { + var app = new CommandLineApplication(); + + // Add an option with symbol, short, long, and value name components + app.Option("-?|-h|--help ", "Show help information", CommandOptionType.SingleValue); + + var helpText = app.GetHelpText(); + + // Verify the option is formatted with comma-space separators + Assert.Contains("-?, -h, --help ", helpText); + } }