Open
Description
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.
[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.
Metadata
Metadata
Assignees
Labels
No labels