commandlineparser / commandlineparser/commandline

[Feature request] Let HelpText.AutoBuild method populate HelpText instance according to parser settings

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

Beschreibung

Currently, when setting `AutoHelp` and/or `AutoVersion` for the parser to `false`, the `HelpText.AutoBuild` method does not acknowledge those parser settings for the respective `HelpText` properties, thus forcing the user to repeat setting those settings for HelpText.

Right now, i have to write something like that:

static void Main(string[] args)
{
using (var cmdLineParser = new Parser(settings => { settings.AutoHelp = false; settings.AutoVersion = false; }))
{
var parserResult = cmdLineParser.ParseArguments(args);
parserResult
.WithNotParsed(errors => DisplayHelp(parserResult, errors))
.WithParsed(Execute);
}
}

static void DisplayHelp(ParserResult result, IEnumerable errs)
{
var helpText = HelpText.AutoBuild(
result,
h =>
{
h.AutoHelp = false;
h.AutoVersion = false;
return h;
}
);
Console.WriteLine(helpText);
}

Note how my code for the `DisplayHelp` method is forced to again set the `AutoHelp` and `AutoVersion` settings for the HelpText to `false` (since they default to `true`, despite the respective parser settings being set to `false`).

Ideally, it would be nice if HelpText.AutoBuild could initialize the HelpText instance with the values from any appropriate settings of the parser used to produce the ParserResult.

(Related discussion: https://github.com/commandlineparser/commandline/issues/414)

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.