commandlineparser / commandlineparser/commandline

Add MapResult example to HelpText Configuration Wiki

Offen
#602 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
4.8k
Forks
478
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.