Can't find ParseArgumentsStrict method from samples
version 2.2
Me either. I stepped back 1 version.
Sorry, it was removed in the rewrite to the latest version. We need to fix that example to look more like the verb examples, which are more up to date. Consuming the arguments should look something like this:
int Main(string[] args) {
return CommandLine.Parser.Default.ParseArguments<Options>(args)
.WithNotParsed(errs => {
// do something with the errors
})
.WithParsed(opt => {
// do things with options
});
}
If you miss ParseArgumentsStrict, you can basically replicate it with the following code:
var writer = new StringWriter();
var parser = new Parser(conf => conf.HelpWriter = writer);
var result = parser.ParseArguments<Options>(args);
result.WithNotParsed(_ => {
Console.WriteLine(writer.ToString());
System.Environment.Exit(1);
})
.WithParsed(opt => {
// do things with options
});
Most helpful comment
Sorry, it was removed in the rewrite to the latest version. We need to fix that example to look more like the verb examples, which are more up to date. Consuming the arguments should look something like this:
If you miss ParseArgumentsStrict, you can basically replicate it with the following code: