commandlineparser / commandlineparser/commandline

Add MapResult example to HelpText Configuration Wiki

Open
#602 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

Please add the following example to the https://github.com/commandlineparser/commandline/wiki/HelpText-Configuration page.

```
class Program {
static int Main(string[] args) {
var parserResult = new Parser(c => c.HelpWriter = null).ParseArguments(args);
return parserResult.MapResult(
(Options opts) => new Run(opts),
errs => DisplayHelp(parserResult, errs)
);
}

static int DisplayHelp(ParserResult parserResult, IEnumerable errs) {
Console.WriteLine(HelpText.AutoBuild(parserResult, h => {
h.AddPreOptionsLine(Environment.NewLine + "Use this tool wisely!");
return h;
}));
return 1;
}
}
```

Also I had a great trouble finding this page, please add more links to it.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.