-
Notifications
You must be signed in to change notification settings - Fork 31
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
Clear previous parse results before starting a new parse #5
Conversation
I didn't review it deeply, but by just compiling the example, it seems that the
but output without any command line flag should be:
also the count will not go higher than one. When using |
I think you can actually leave the |
I merged and removed the |
OK, it's up to you. I've implemented one more feature that my project needs, a "mandatory" or "required" option: it must be set from command line, otherwise an exception is thrown. It is useful for making a "filename" option, as you cannot set any default value it. Actually it serves as intermediate level between ValueTemplate and Value, and it can be merged with ValueTemplate completely. I'll push it to my branch, but it might be not 100% completed yet. |
That does not work in my environment. If Switch is assignes a remote value at the 1st parse, it is still assigned to true after 2nd parse, regardless of its input. |
did you try with the current version? 722a55d |
Thanks, works well now! |
These changes are another outcome of integrating Popl into our unit tests. The idea of our tests is to set up options once during static initialization, and check whether different arrays of arguments are parsed to a meaningful output or not.
Thus we need to perform a cleanup values before parse starts, but keep names and types of each option. As I see, the "non-options" results are cleared already, so I put my code nearby to it.
Cleaning ValueTemplate is straightforward, however I don't understand if count_ cannot be equal to options_.size(). If yes, it might be removed.
Switch is more tricky, as it updates remote value in ctor. I changed its behavior, so on clears it assigns to false, and does otherwise on parse. In my implementation, options_ vector of Switch is not able to contain more than 1 element, however I consider that as a natural thing, as there are only two states possible for it (switch exists in argv or it does not)