-
Notifications
You must be signed in to change notification settings - Fork 21
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
Added support for not saving options, get by name. #9
base: master
Are you sure you want to change the base?
Conversation
Motivation: I don't want to save all my options. I would rather just get options by name. There for I added some methods: <T> T getValue(String long_form) <T> T getValue(String long_form, T default) <T> Collection<T> getValues(String long_form) They work the same way as getOptionValue(Option<T> o) etc... A sanity test is written but more testing should probably be done. Signed-off-by: Tim Henderson <[email protected]>
I have some issues with your patch
On the other hand, the long forms currently are the way the options are identified, instead of the Option's equals/hashCode methods. Therefore I'm not generally against this approach. |
There should probably be more testing but I believe it is in a separate test case right now. Or do you mean in a separate file?
This is true. I guess I am more of a fan of this than of having both the option variable and the value of the option variable. Let me know what you want more specifically on the testing side and I will do it. |
Yes I think a separate file in the Maven test directory should be used. That way the test will run automatically on build :-) |
Ok. I can do that. I will create a new test file and move the test to that On Fri, Feb 15, 2013 at 8:45 AM, ooxi [email protected] wrote:
|
Nevertheless I am quite sceptical about the new API. The hole point of JArgs 2.0 (in contrast to the old 1.x branch) is easy type safety: By providing the generated If you refer to the options by name instead you will once again have to do manual type casts. For example Collection<String> myStrings = myParser.<String>getValues("my-string-argument") to get a collection of strings, which is not much better than the old way of doing Collection<String> myStrings = (Collection<String>)myParser.getValues("my-string-argument") Therefore I suggest you provide the new API not in the core |
IMO I don't think getopt implementations should be doing typing at all. I guess my feeling is this: there is no free lunch even with a nice type
|
If it's worth doing, it's worth doing in the same class. I don't see that subclassing I'm sorry that I haven't yet taken the time to review the proposed code and provide substantive feedback, but I will as time allows. |
Okay, so I took a look. As far as I can tell, you really just want to be able to pluck out the string value for "myopt", at a low level, and you don't care about any of the checking that CmdLineParser does for allowed/disallowed options. If that's the case, splicing on a method for "just get this damn option value" isn't the approach I'd suggest. Rather, how about extracting the code in |
Steve, Thanks for taking a look.
which is how I am currently using it. You will need the type tags but not
Maybe I will take a shot at that. |
I agree that providing |
Motivation: I don't want to save all my options. I would rather just
get options by name. There for I added some methods:
They work the same way as getOptionValue(Option o) etc...
A sanity test is written but more testing should probably be done.