[
https://issues.apache.org/jira/browse/CLI-254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14596504#comment-14596504
]
Benedikt Ritter commented on CLI-254:
-------------------------------------
Translating the groovy test case from above gives the following (which also
fails):
{code:java}
@Test
public void testQuotes() throws Exception {
DefaultParser parser = new DefaultParser();
Options ops = new Options();
ops.addOption(Option.builder("f").longOpt("json-filter").desc("jq
expression").hasArg().build());
String[] vals = new String[8];
vals[0] = "test";
vals[1] = "t\"es\"t";
vals[2] = "\'test";
vals[3] = "test\'";
vals[4] = "\'test\'";
vals[5] = "\"test";
vals[6] = "test\"";
vals[7] = "\"test\"";
for (String val : vals) {
CommandLine cli = parser.parse(ops, new String[]{"-f", val});
assertEquals("Parsing " + val, val, cli.getOptionValue("f"));
}
}
{code}
> "test" gets parsed as test, quotes die :-(
> ------------------------------------------
>
> Key: CLI-254
> URL: https://issues.apache.org/jira/browse/CLI-254
> Project: Commons CLI
> Issue Type: Bug
> Affects Versions: 1.3
> Reporter: Alexander Petrossian (PAF)
> Fix For: 1.4
>
>
> {code}
> def cli = new CliBuilder()
> cli.with {
> f longOpt:'json-filter','jq expression', args: 1
> }
> def vals = ['test', 't"es"t',
> "'test", "test'", "'test'",
> '"test', 'test"', '"test"']
> vals.each {
> def opt = cli.parse(['-f', it])
> assert opt.f == it
> }
> {code}
> It fails on last entry: "test".
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)