Open jawn opened 9 years ago
Hi @jawn, happy you choose this library.
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.
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.