You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the latest nuget of the version 2.0 pre-release, I can display help text like this:
var results = Parser.Default.ParseArguments<Options>(args)
.WithParsed(opts => /* handle options here */)
if (results.Tag == ParserResultType.NotParsed)
{
var helpText = HelpText.AutoBuild(results);
Console.WriteLine(helpText);
}
Is there a way to do this within the fluent syntax?
Something like
var results = Parser.Default.ParseArguments(args)
.WithNotParsed(opts => Console.WriteLine(HelpText.AutoBuild()));
.WithParsed(opts => /* handle options here */)
Since AutoBuild() requires results, this can't be called within the fluent syntax. That's already logged as #88, however I would like to know whether a different solution is available.
The text was updated successfully, but these errors were encountered:
If you invoke the parser using default singleton like in posted sample, you don't need any call to AutoBuild(). This is because this instance is pre-configured with a ParserSettings.HelpWriter set to Console.Error and when this property has a value the help screen is automatically generated and displayed.
In this case just stay with the WithParsed and job is done.
If you want handle help text manually, there's various way to do it from using AutoBuild() to mixing various intermediate step to get whatever customization you want.
Any way a possible fluent version, could be an extension to ParserResult like result.AutoBuild()...
If this not helped, please let me know.
PS: If possible use ParserResult extension methods instead of manually checking Tag discriminator and cast the instance.
Wednesday Aug 12, 2015 at 08:58 GMT
Originally opened as gsscoder/commandline#223
Using the latest nuget of the version 2.0 pre-release, I can display help text like this:
Is there a way to do this within the fluent syntax?
Something like
var results = Parser.Default.ParseArguments(args)
.WithNotParsed(opts => Console.WriteLine(HelpText.AutoBuild()));
.WithParsed(opts => /* handle options here */)
Since AutoBuild() requires results, this can't be called within the fluent syntax. That's already logged as #88, however I would like to know whether a different solution is available.
The text was updated successfully, but these errors were encountered: