Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.4
-
None
-
None
Description
with the following configuration...
DefaultParser parser = new DefaultParser(); Options opts = new Options(); Option pager = Option.builder(null) .longOpt("cmd") .hasArg() .numberOfArgs(Option.UNLIMITED_VALUES) .build(); opts.addOption(pager);
This works as long as the value of cmd is a single value.
$ myApp --cmd='less'
The following does not work, as soon as we add options to less
$ myApp --cmd='less -XFR' Exception in thread "main" com.cevaris.ag4j.cli.AppArgsException: org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -XFR at com.cevaris.ag4j.cli.ApacheAppArgs.parse(ApacheAppArgs.java:33) at com.cevaris.ag4j.Main.main(Main.java:61) Caused by: org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -XFR at org.apache.commons.cli.DefaultParser.handleUnknownToken(DefaultParser.java:360) at org.apache.commons.cli.DefaultParser.handleConcatenatedOptions(DefaultParser.java:702) at org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:533) at org.apache.commons.cli.DefaultParser.handleToken(DefaultParser.java:243) at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:120) at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:76) at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:60) at com.cevaris.ag4j.cli.ApacheAppArgs.parse(ApacheAppArgs.java:31)'
The following works, as long as we use a space to separate option & value, rather than using an =
$ myApp --cmd 'less -XFR' # works $ myApp --cmd='less -XFR' # fails
Attempted to use .valueSeparator() with no luck.