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

Using AcceptAdditionalArguments=false always throws exception #45

Closed
ghost opened this issue Jun 12, 2017 · 1 comment
Closed

Using AcceptAdditionalArguments=false always throws exception #45

ghost opened this issue Jun 12, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 12, 2017

When setting the parser.AdditionalArgumentsSettings.AcceptAdditionalArguments to false it always throws an exception, regardless of the arguments provided.

Example:

var stateArgument = new EnumeratedValueArgument<string>('s', "state", "Filters the list for the specific state.", new[] { "open", "closed", "all" });

var parser = new CommandLineParser.CommandLineParser();
parser.Arguments.Add(stateArgument);

// parses just fine
parser.ParseCommandLine(new[] { "--state", "open" });

// when using AcceptAdditionalArguments=false it crashes with the same (valid arguments)
var crashingParser = new CommandLineParser.CommandLineParser();
crashingParser.Arguments.Add(stateArgument);
crashingParser.AdditionalArgumentsSettings.AcceptAdditionalArguments = false;
crashingParser.ParseCommandLine(new[] { "--state", "open" });

Fix: one additional if check in ParseAdditionalArguments.

Proposed fix as a pull request.

@ghost ghost changed the title Using AcceptAdditionalArguments=true always throws exception Using AcceptAdditionalArguments=falsealways throws exception Jun 12, 2017
@ghost ghost changed the title Using AcceptAdditionalArguments=falsealways throws exception Using AcceptAdditionalArguments=false always throws exception Jun 12, 2017
@j-maly j-maly closed this as completed Jun 13, 2017
@j-maly
Copy link
Owner

j-maly commented Jun 13, 2017

Thanks for the fix, included in version 3.0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant