args4j icon indicating copy to clipboard operation
args4j copied to clipboard

Parsing with option value delimiter other than "=" does not work

Open sbyrx opened this issue 7 years ago • 2 comments

In this commit CommandLineParser was modified to use parserProperties.getOptionValueDelimiter() instead of supporting only "=" as a delimiter.

However, it appears as though the splitToken() method inside of CmdLineImpl was missed in this change:

         /**
         * Used when the current token is of the form "-option=value",
         * to replace the current token by "value", as if this was given as two tokens "-option value"
         */
        void splitToken() {
            if (pos < args.length && pos >= 0) {
                int idx = args[pos].indexOf("=");
                if (idx > 0) {
                    args[pos] = args[pos].substring(idx + 1);
                }
            }
        }

It is still using a hard-coded equals sign to determine the index of the parameter to remove instead of calling parserProperties.getOptionValueDelimiter().

This means that, for example, when I change the option value delimiter to ":", and try and parse something like "-e:testing" what gets passed through as a parameter value is "-e:testing" when I would expect to have just "testing" as a value.

sbyrx avatar May 16 '17 17:05 sbyrx

@kohsuke I have implemented a fix for this issue, and I would like to contribute it. Could you please give me permission to push up a branch and create a PR?

sbyrx avatar May 18 '17 13:05 sbyrx

Scratch that, PR opened!

sbyrx avatar May 18 '17 13:05 sbyrx