Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsolete API using throwOnUnexpectedArg #339

Closed
natemcmaster opened this issue Feb 9, 2020 · 0 comments · Fixed by #340
Closed

Obsolete API using throwOnUnexpectedArg #339

natemcmaster opened this issue Feb 9, 2020 · 0 comments · Fixed by #340
Assignees
Labels
closed-resolved This issue is closed because the work done to resolve it is complete. enhancement
Milestone

Comments

@natemcmaster
Copy link
Owner

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;
});
@natemcmaster natemcmaster added this to the 3.0 milestone Feb 9, 2020
@natemcmaster natemcmaster changed the title Remove obsolete API using throwOnUnexpectedArg Obsolete API using throwOnUnexpectedArg Feb 9, 2020
@natemcmaster natemcmaster modified the milestones: 3.0, 2.6 Feb 9, 2020
@natemcmaster natemcmaster self-assigned this Feb 9, 2020
@natemcmaster natemcmaster added the closed-resolved This issue is closed because the work done to resolve it is complete. label Feb 19, 2020
skolima added a commit to NuKeeperDotNet/NuKeeper that referenced this issue May 4, 2020
* 📦 Automatic update of McMaster.Extensions.CommandLineUtils to 3.0.0

* Updated library usage as suggested by upstream

natemcmaster/CommandLineUtils#339
Viir added a commit to pine-vm/pine that referenced this issue May 28, 2020
Learn about the developments in upstream projects now.
For the changes in the command-line interface library, see natemcmaster/CommandLineUtils#339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-resolved This issue is closed because the work done to resolve it is complete. enhancement
Projects
None yet
1 participant