Skip to content

Auto-help has unsightly blank lines #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rmunn opened this issue Sep 28, 2015 · 5 comments
Closed

Auto-help has unsightly blank lines #244

rmunn opened this issue Sep 28, 2015 · 5 comments

Comments

@rmunn
Copy link
Contributor

rmunn commented Sep 28, 2015

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)
@rmunn
Copy link
Contributor Author

rmunn commented Oct 5, 2015

I can confirm that that patch works to fix this bug. I forked the repo and built a new version with that one-line change, and tested my program against it. And with that change, the superfluous blank lines no longer show up.

@gsscoder
Copy link
Owner

gsscoder commented Oct 5, 2015

📎 Please read: #250. Thanks for collaboration and patience! 😅
Giacomo
P.S.: valid only for me, if a main contrib. is available he's obviously free to support devs/users of the project.

@rmunn
Copy link
Contributor Author

rmunn commented Nov 6, 2015

Turned my patch above into a pull request. I used this in my project and it does what I expected: if my AssemblyLicense and AssemblyUsage attributes specify just one line, then just one line is all I get:

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

@rmunn
Copy link
Contributor Author

rmunn commented Nov 27, 2015

@gsscoder - Any comment on this issue or on PR #261? It's a one-line change, so I don't think it would be too hard to review...

@nemec
Copy link
Collaborator

nemec commented Dec 12, 2015

Merged. Unfortunately, @gsscoder holds the keys to the NuGet kingdom and he is away for some time (#271) so there won't be an official package until he gets back.

However, NuGet does offer multiple package sources so if you create you own (with the same package name), give it a minor version bump, and put it in your custom NuGet source (we use a simple file share!) you should be able to "upgrade" through the VS UI and then upgrade again once a new official package goes out. The snk is part of the repo so you shouldn't have any Strong Naming issues even when creating your own package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants