You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RenderParsingErrorsText() returns a string with linebreaks if there are multiple errors. When passed to Add<>OptionsLine, it is wrapped every 80 characters regardless of newlines, causing incorrect wrapping.
[ParserState]
public IParserState LastParserState { get; set; }
[Option('a', "qwe", Required = true)]
public string a { get; set; }
[Option('b', "asd", Required = true)]
public double b { get; set; }
[Option('c', "zxc", Required = true)]
public bool c { get; set; }
[HelpOption]
public string GetUsage()
{
var help = new HelpText();
// ...
if (this.LastParserState.Errors.Count > 0)
{
var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
if (!string.IsNullOrEmpty(errors))
{
help.AddPreOptionsLine(string.Concat("\n", "ERROR(S):"));
help.AddPreOptionsLine(errors);
}
}
// ...
return help;
}
>foo.exe
ERROR(S):
-a/--qwe required option is missing.
-b/--asd required option is
missing.
-c/--zxc required option is missing.
As you can see, the second error line gets incorrectly wrapped.
The text was updated successfully, but these errors were encountered:
Comment by turch Thursday Mar 14, 2013 at 15:52 GMT
Same answer, master branch :)
I haven't made any changes to my fork since this would be more than a one-line change that would probably be made irrelevant by the development branch changes.
Issue by turch
Wednesday Mar 13, 2013 at 21:07 GMT
Originally opened as gsscoder/commandline#69
Using the sample code in https://github.com/gsscoder/commandline/wiki/Display-A-Help-Screen section "Handling Parsing Errors" to print errors:
RenderParsingErrorsText() returns a string with linebreaks if there are multiple errors. When passed to Add<>OptionsLine, it is wrapped every 80 characters regardless of newlines, causing incorrect wrapping.
As you can see, the second error line gets incorrectly wrapped.
The text was updated successfully, but these errors were encountered: