Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support for String valueSeparator #13

njadhav opened this Issue · 6 comments

2 participants


It seems that the ArgumentAcceptingOptionSpec does not have any method to specify the value separator as a String. Why is that? Internally, it does make use of a String to represent valueSeparator. I need to have ": :" as the value separator for my option values.


Can you give an example of a command line you'd like JOpt Simple to parse, but currently doesn't?


solve --question=apple:fruit::jasmine:?

I need to split the "apple:fruit::jasmine:?" as "apple:fruit" and "jasmine:?". So, in this case the value separator needs to be "::" a string. I was able to do that sometime back, don't exactly remember the version and I unfortunately lost the code as it was just a POC. But right now, there is nothing to provide String as a value separator even thought it internally uses String.


It looks as though your intended option arguments are SAT-style analogies "X is to Y as Z is to W".

One possibility would be to configure the parser like so:


where Analogy is your own "value type" (one-arg String ctor or public static valueOf(String) method); Analogy could then take on the responsibility for parsing the value.

On the other hand, ArgumentAcceptingOptionSpec.withValuesSeparatedBy() could be overloaded to accept a String separator rather than a char separator. It isn't this way now because no one had asked about it and I couldn't imagine wanting it.

Let me know your preference.


I have a class which overloads the function right now but it would have been better if there was one in place.

Thank you for your time.


@njadhav Have a look at this and let me know whether it suits your needs. Thanks!


I have already implemented this functionality in a sub-class but this looks good. Thanks a lot.

@pholser pholser closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.