[
https://issues.apache.org/jira/browse/CLI-260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053227#comment-16053227
]
ASF GitHub Bot commented on CLI-260:
------------------------------------
Github user chtompki commented on the issue:
https://github.com/apache/commons-cli/pull/14
My impression base on my reading of the
[CLI-260](https://issues.apache.org/jira/browse/CLI-260) is that from this code:
```java
private DefaultParser parser;
private Options options;
@Before
public void setUp()
{
parser = new DefaultParser();
options = new Options()
.addOption("a", "enable-a", false, "turn [a] on or off")
.addOption("b", "bfile", true, "set the value of [b]")
.addOption("c", "copt", false, "turn [c] on or off")
.addOption("k", "kopt", true, "set value of k");
}
@Test
public void testProblem() throws Exception
{
String[] args = new String[] {"-k'option=value'"};
CommandLine cl = parser.parse(options, args);
String temp = "temp";
}
```
we get this exception:
```
org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option:
-k'option=value'
at
org.apache.commons.cli.DefaultParser.handleUnknownToken(DefaultParser.java:359)
at
org.apache.commons.cli.DefaultParser.handleLongOptionWithEqual(DefaultParser.java:439)
at
org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:568)
at
org.apache.commons.cli.DefaultParser.handleToken(DefaultParser.java:242)
at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:119)
at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:75)
at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:59)
at
org.apache.commons.cli.bug.BugCLI260Test.testProblem(BugCLI260Test.java:71)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:547)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
```
@jlm429, @britter - thoughts?
> Opption parsing does not recognize quotes as end of option
> ----------------------------------------------------------
>
> Key: CLI-260
> URL: https://issues.apache.org/jira/browse/CLI-260
> Project: Commons CLI
> Issue Type: Bug
> Components: CLI-1.x
> Affects Versions: 1.3.1
> Reporter: Ralf Edmund Stranzenbach
> Assignee: Rob Tompkins
>
> A command String like
> *-k'option=value'*
> does not recognize the string *option=value* as the parameter of *-k*.
> Instead *-k'option* is parsed as the option and *value* as parameter.
> Workaround: use *-k='option=value'* instead. But users might think otherwise.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)