args4j icon indicating copy to clipboard operation
args4j copied to clipboard

Wrong operand name displayed when "key=value" syntax is used

Open anba opened this issue 11 years ago • 1 comments

Multiple OptionHandler sub-classes use Parameters#getParameter(...) with -1 as the index parameter, e.g. EnumOptionHandler. This approach does not work when the "key=value" syntax is used, see splitToken() in CmdLineParser.CmdLineImpl for why this is not working.

anba avatar May 20 '14 08:05 anba

FWIW,

Minimal code to reproduce

import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

public class Foo {

    @Option(name = "--foo")
    String foo;

    @Option(name = "--val")
    int val;

    public static void main(String[] args) throws Exception {
        new CmdLineParser(new Foo())
                .parseArgument(new String[] {
                        "--foo=bar",
                        "--val=abc",
                });
    }
}

throws:

org.kohsuke.args4j.CmdLineException: "abc" is not a valid value for "bar"

atnak avatar Dec 25 '18 04:12 atnak