commandlineparser / commandlineparser/commandline

Make the Error class more useful

Offen
#183 0 Kommentare 3 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

Consider the following code:
```cs
parserResult.MapResult(
options => 0,
errs =>
{
foreach (var error in errors)
{
Console.Error(error); //right now this will just print out the Error type
}
return 1;
});
```

Right now building the error string is a manual process of checking the type, casting to the correct subclass, etc. Fortunately that logic already exists here:
https://github.com/commandlineparser/commandline/blob/7aa501d534a657c388f94f66127b4f8dde64ac59/src/CommandLine/Text/SentenceBuilder.cs#L110

All we have to do is put it in `Error.ToString()`...

Another useful addition would be something like `HelpText.AddError(Error)` / `HelpText.AddErrors(Ienumerable)` .

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.