commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex P <>
Subject [cli] GnuParser vs DefaultParser
Date Wed, 17 Jun 2015 22:02:48 GMT
Hi All,

Not sure if that is a change in API or bug in DefaultParser.

If I use GnuParser (what I used in 1.2) like:
    public void testUnlimitedArgs() throws Exception
        String[] args = new String[] {"-unlimited", "one", "two", "-one",

        Options options = new Options();

        CommandLine cl = parser.parse(options, args);

        assertTrue("Confirm -unlimited is set", cl.hasOption("unlimited"));
        assertEquals("number of arg for -unlimited", 2,
        assertTrue("Confirm -one is set", cl.hasOption("one"));
        assertEquals("number of arg for -one", 1,
everything works fine.

But in 1.3 GnuParser is deprecated and if I do the same options with
DefaultParser, it becomes dependent on arguments position - my original
line fails, but if I change it to
        String[] args = new String[] {"-one", "alpha", "-unlimited", "one",
test succeed.

Any thoughts?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message