Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CommandLine/Text/HelpText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public static HelpText AutoBuild<T>(ParserResult<T> parserResult, int maxDisplay
var errors = ((NotParsed<T>)parserResult).Errors;

if (errors.Any(e => e.Tag == ErrorType.VersionRequestedError))
return new HelpText(HeadingInfo.Default){MaximumDisplayWidth = maxDisplayWidth }.AddPreOptionsLine(Environment.NewLine);
return new HelpText($"{HeadingInfo.Default}{Environment.NewLine}"){MaximumDisplayWidth = maxDisplayWidth }.AddPreOptionsLine(Environment.NewLine);

if (!errors.Any(e => e.Tag == ErrorType.HelpVerbRequestedError))
return AutoBuild(parserResult, current => DefaultParsingErrorsHandler(parserResult, current), e => e, maxDisplayWidth: maxDisplayWidth);
Expand Down
36 changes: 36 additions & 0 deletions tests/CommandLine.Tests/Unit/Issue418Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using CommandLine.Text;
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommandLine.Tests.Fakes;
using Xunit;
using FluentAssertions;

namespace CommandLine.Tests.Unit
{
//issue#418, --version does not print a new line at the end cause trouble in Linux
public class Issue418Tests
{

[Fact]
public void Explicit_version_request_generates_version_info_screen_with_eol()
{
// Fixture setup
var help = new StringWriter();
var sut = new Parser(config => config.HelpWriter = help);

// Exercize system
sut.ParseArguments<Simple_Options>(new[] { "--version" });
var result = help.ToString();
// Verify outcome
var lines = result.ToNotEmptyLines();
result.Length.Should().BeGreaterThan(0);
result.Should().EndWith(Environment.NewLine);
result.ToNotEmptyLines().Length.Should().Be(1);

// Teardown
}
}
}
2 changes: 2 additions & 0 deletions tests/CommandLine.Tests/Unit/ParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ public void Parse_options_with_shuffled_index_values()
Assert.Equal("one", args.Arg1);
Assert.Equal("two", args.Arg2);
});

}


Expand All @@ -823,5 +824,6 @@ public void Blank_lines_are_inserted_between_verbs()
lines[10].Should().BeEquivalentTo("version Display version information.");
// Teardown
}

}
}