[
https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150781#comment-13150781
]
Hartmut Lang commented on CLI-216:
----------------------------------
I thought of a use-case, but so far could not find one.
Look at the test-cases below. They run perfect with Default- and Posix-Parser.
{code}
public void testBursting2() throws Exception
{
String[] args = new String[]{"-zxvf", "file1", "-xzvf", "file2"};
Options opts = new Options();
opts.addOption(OptionBuilder.create("x"));
opts.addOption(OptionBuilder.create("v"));
opts.addOption(OptionBuilder.create("z"));
opts.addOption(OptionBuilder.hasArg().create("f"));
opts.addOption(OptionBuilder.hasArg().withLongOpt("zxvf").create());
CommandLine cl = parser.parse(opts, args);
assertTrue("Confirm -zxvf is set", cl.hasOption("zxvf"));
assertEquals("Confirm arg of -zxvf", "file1" ,
cl.getOptionValue("zxvf"));
assertTrue("Confirm -x is set", cl.hasOption("x"));
assertTrue("Confirm -v is set", cl.hasOption("v"));
assertTrue("Confirm -z is set", cl.hasOption("z"));
assertTrue("Confirm -f is set", cl.hasOption("f"));
assertEquals("Confirm arg of -f", "file2" , cl.getOptionValue("f"));
}
public void testBursting3() throws Exception
{
String[] args = new String[]{"-zx", "file1", "-zvxf", "file2"};
Options opts = new Options();
opts.addOption(OptionBuilder.create("x"));
opts.addOption(OptionBuilder.create("v"));
opts.addOption(OptionBuilder.create("z"));
opts.addOption(OptionBuilder.hasArg().create("f"));
opts.addOption(OptionBuilder.hasArg().withLongOpt("zxvf").create());
CommandLine cl = parser.parse(opts, args);
assertTrue("Confirm -zxvf is set", cl.hasOption("zxvf"));
assertEquals("Confirm arg of -zxvf", "file1" ,
cl.getOptionValue("zxvf"));
assertTrue("Confirm -x is set", cl.hasOption("x"));
assertTrue("Confirm -v is set", cl.hasOption("v"));
assertTrue("Confirm -z is set", cl.hasOption("z"));
assertTrue("Confirm -f is set", cl.hasOption("f"));
assertEquals("Confirm arg of -f", "file2" , cl.getOptionValue("f"));
}
{code}
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
> Key: CLI-216
> URL: https://issues.apache.org/jira/browse/CLI-216
> Project: Commons CLI
> Issue Type: Improvement
> Components: Parser
> Affects Versions: 1.3
> Reporter: Emmanuel Bourg
> Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar
> -zxvf), but in many cases this behavior is not desirable. This should be made
> optional.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira