Skip to content

Commit 77f4840

Browse files
authored
Merge pull request #280 from ElijahReva/usage-fix
Fix HelpText.AutoBuild Usage spacing
2 parents 3c7f0d6 + 53da5bb commit 77f4840

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/CommandLine/Text/HelpText.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ internal static void AddLine(StringBuilder builder, string value, int maximumLen
640640
throw new ArgumentOutOfRangeException(nameof(value));
641641
}
642642

643-
value = value.Trim();
643+
value = value.TrimEnd();
644644

645645
builder.AppendWhen(builder.Length > 0, Environment.NewLine);
646646
do

tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte
505505
var helpText = HelpText.AutoBuild(fakeResult);
506506

507507
// Verify outcome
508-
var text = helpText.ToString();
509-
var lines = text.ToNotEmptyLines().TrimStringArray();
508+
var text = helpText.ToString();
509+
var lines = text.ToNotEmptyLines();
510510
#if !PLATFORM_DOTNET
511511
lines[0].Should().StartWithEquivalent("CommandLine");
512512
lines[1].Should().StartWithEquivalent("Copyright (c)");
@@ -516,28 +516,28 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte
516516
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
517517
#endif
518518
lines[2].ShouldBeEquivalentTo("ERROR(S):");
519-
lines[3].ShouldBeEquivalentTo("Token 'badtoken' is not recognized.");
519+
lines[3].ShouldBeEquivalentTo(" Token 'badtoken' is not recognized.");
520520
lines[4].ShouldBeEquivalentTo("USAGE:");
521521
lines[5].ShouldBeEquivalentTo("Normal scenario:");
522-
lines[6].ShouldBeEquivalentTo("mono testapp.exe --input file.bin --output out.bin");
522+
lines[6].ShouldBeEquivalentTo(" mono testapp.exe --input file.bin --output out.bin");
523523
lines[7].ShouldBeEquivalentTo("Logging warnings:");
524-
lines[8].ShouldBeEquivalentTo("mono testapp.exe -w --input file.bin");
524+
lines[8].ShouldBeEquivalentTo(" mono testapp.exe -w --input file.bin");
525525
lines[9].ShouldBeEquivalentTo("Logging errors:");
526-
lines[10].ShouldBeEquivalentTo("mono testapp.exe -e --input file.bin");
527-
lines[11].ShouldBeEquivalentTo("mono testapp.exe --errs --input=file.bin");
526+
lines[10].ShouldBeEquivalentTo(" mono testapp.exe -e --input file.bin");
527+
lines[11].ShouldBeEquivalentTo(" mono testapp.exe --errs --input=file.bin");
528528
lines[12].ShouldBeEquivalentTo("List:");
529-
lines[13].ShouldBeEquivalentTo("mono testapp.exe -l 1,2");
529+
lines[13].ShouldBeEquivalentTo(" mono testapp.exe -l 1,2");
530530
lines[14].ShouldBeEquivalentTo("Value:");
531-
lines[15].ShouldBeEquivalentTo("mono testapp.exe value");
532-
lines[16].ShouldBeEquivalentTo("-i, --input Set input file.");
533-
lines[17].ShouldBeEquivalentTo("-i, --output Set output file.");
534-
lines[18].ShouldBeEquivalentTo("--verbose Set verbosity level.");
535-
lines[19].ShouldBeEquivalentTo("-w, --warns Log warnings.");
536-
lines[20].ShouldBeEquivalentTo("-e, --errs Log errors.");
537-
lines[21].ShouldBeEquivalentTo("-l List.");
538-
lines[22].ShouldBeEquivalentTo("--help Display this help screen.");
539-
lines[23].ShouldBeEquivalentTo("--version Display version information.");
540-
lines[24].ShouldBeEquivalentTo("value pos. 0 Value.");
531+
lines[15].ShouldBeEquivalentTo(" mono testapp.exe value");
532+
lines[16].ShouldBeEquivalentTo(" -i, --input Set input file.");
533+
lines[17].ShouldBeEquivalentTo(" -i, --output Set output file.");
534+
lines[18].ShouldBeEquivalentTo(" --verbose Set verbosity level.");
535+
lines[19].ShouldBeEquivalentTo(" -w, --warns Log warnings.");
536+
lines[20].ShouldBeEquivalentTo(" -e, --errs Log errors.");
537+
lines[21].ShouldBeEquivalentTo(" -l List.");
538+
lines[22].ShouldBeEquivalentTo(" --help Display this help screen.");
539+
lines[23].ShouldBeEquivalentTo(" --version Display version information.");
540+
lines[24].ShouldBeEquivalentTo(" value pos. 0 Value.");
541541

542542
// Teardown
543543
}

0 commit comments

Comments
 (0)