Skip to content

Commit c090655

Browse files
Copilotdanmoseley
andcommitted
Fix help option formatting to use comma-space separator instead of pipe
Co-authored-by: danmoseley <[email protected]>
1 parent a9dff7a commit c090655

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/Shared/CommandLineUtils/CommandLine/CommandLineApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,11 @@ public string GetHelpText(string commandName = null)
493493

494494
optionsBuilder.AppendLine();
495495
optionsBuilder.AppendLine("Options:");
496-
var maxOptLen = options.Max(o => o.Template.Length);
496+
var maxOptLen = options.Max(o => o.GetDisplayText().Length);
497497
var outputFormat = string.Format(CultureInfo.InvariantCulture, " {{0, -{0}}}{{1}}", maxOptLen + 2);
498498
foreach (var opt in options)
499499
{
500-
optionsBuilder.AppendFormat(CultureInfo.InvariantCulture, outputFormat, opt.Template, opt.Description);
500+
optionsBuilder.AppendFormat(CultureInfo.InvariantCulture, outputFormat, opt.GetDisplayText(), opt.Description);
501501
optionsBuilder.AppendLine();
502502
}
503503
}

src/Shared/CommandLineUtils/CommandLine/CommandOption.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ public string Value()
100100
return HasValue() ? Values[0] : null;
101101
}
102102

103+
public string GetDisplayText()
104+
{
105+
var parts = new List<string>();
106+
107+
if (!string.IsNullOrEmpty(SymbolName))
108+
{
109+
parts.Add($"-{SymbolName}");
110+
}
111+
112+
if (!string.IsNullOrEmpty(ShortName))
113+
{
114+
parts.Add($"-{ShortName}");
115+
}
116+
117+
if (!string.IsNullOrEmpty(LongName))
118+
{
119+
parts.Add($"--{LongName}");
120+
}
121+
122+
var result = string.Join(", ", parts);
123+
124+
if (!string.IsNullOrEmpty(ValueName))
125+
{
126+
result += $" <{ValueName}>";
127+
}
128+
129+
return result;
130+
}
131+
103132
private static bool IsEnglishLetter(char c)
104133
{
105134
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');

0 commit comments

Comments
 (0)