Skip to content

Auto-help has unsightly blank lines #244

Closed
@rmunn

Description

@rmunn

If I define AssemblyLicense and/or AssemblyUsage in my AssemblyInfo.cs file, the automatically-produced --help text has unsightly blank lines:

My.App.Name 1.0.0.0
Copyright © 2015 Robin Munn
Code licensed under the MIT License (http://rmunn.mit-license.org/)




USAGE:
my-app.exe (operation) [-i input-fname] [-o output-fname]





  first-operation    Do something

I believe this is the result of a bug in src/CommandLine/Text/MultiLineTextAttribute.cs, where AddToHelpText adds all lines instead of only the non-blank lines. Here's a patch (UNTESTED so far) that I believe may fix the problem:

diff --git a/src/CommandLine/Text/MultiLineTextAttribute.cs b/src/CommandLine/Text/MultiLineTextAttribute.cs
index 339c65e..8060735 100644
--- a/src/CommandLine/Text/MultiLineTextAttribute.cs
+++ b/src/CommandLine/Text/MultiLineTextAttribute.cs
@@ -150,7 +150,7 @@ namespace CommandLine.Text
         internal HelpText AddToHelpText(HelpText helpText, Func<string, HelpText> func)
         {
             var strArray = new[] { line1, line2, line3, line4, line5 };
-            return strArray.Aggregate(helpText, (current, line) => func(line));
+            return strArray.Take(GetLastLineWithText(strArray)).Aggregate(helpText, (current, line) => func(line));
         }

         internal HelpText AddToHelpText(HelpText helpText, bool before)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions