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

Interpreter should reset options and positional parameters to their initial value before parsing new input #354

Closed
remkop opened this issue Apr 12, 2018 · 0 comments
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Apr 12, 2018

Currently, if a CommandSpec is constructed programmatically, each option and positional parameter by default has an ObjectBinding where the value(s) matched on the command line is/are stored.

These values should be reset to their initial value every time before new input is parsed.

Note that in most cases this is not a problem since the interpreter already keeps track of whether an option has previously been seen or not, and initializes a new Collection or Map the first time the option or positional parameter is encountered.

However, it is best to call option.setValue(option.initialValue()) for all options and positional parameters so there is consistent behaviour for all types, not just java.util classes.

@remkop remkop added this to the 3.0 milestone Apr 12, 2018
@remkop remkop changed the title Interpreter should clear ObjectBinding before parsing new input Interpreter should reset options and positional parameters to their initial value before parsing new input Apr 12, 2018
@remkop remkop closed this as completed in 0607c98 Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant