-
-
Notifications
You must be signed in to change notification settings - Fork 263
Closed
Labels
closed-resolvedThis issue is closed because the work done to resolve it is complete.This issue is closed because the work done to resolve it is complete.enhancement
Milestone
Description
In 2.6, API using "ThrowOnUnexpectedArg" has been made obsolete in favor of the enum UnrecognizedArgumentHandling. This API will be removed in 3.0.
Here is how the old behavior maps to the new API.
ThrowOnUnexpectedArg |
UnrecognizedArgumentHandling |
|---|---|
true |
Throw |
false |
StopParsingAndCollect |
Here are some examples of obsolete code and the recommended replacement.
Obsolete constructors
var app = new CommandLineApplication(throwOnUnexpectedArg: false);Recommended replacement
var app = new CommandLineApplication
{
UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect
};Obsolete properties
CommandLineApplication app;
app.ThrowOnUnexpectedArg = true;
app.ThrowOnUnexpectedArg = false;
[Command(ThrowOnUnexpectedArgument = false)]
private class MySubcommand
{}Recommended replacement
CommandLineApplication app;
app.UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.Throw;
app.UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect;
[Command(UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect)]
private class MySubcommand
{}Obsolete methods
app.Command("subcommand", subcmd =>
{
subcmd.Description = "My subcommand";
},
throwOnUnexpectedArg: false);Recommended replacement
app.Command("subcommand", subcmd =>
{
subcmd.Description = "My subcommand";
subcmd.UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect;
});Metadata
Metadata
Assignees
Labels
closed-resolvedThis issue is closed because the work done to resolve it is complete.This issue is closed because the work done to resolve it is complete.enhancement