I have recently upgraded my project to Picocli 4.2.0, including the removal of all deprecated method calls, and I have been continuing the work I described here. I'm running into the same problem again -- I have a field that doesn't seem to reset. The only thing that's different about this from my other question is that now the field is a collection. The code looks like this:
@Command(name="watch", description="Alters the set of watched productions", subcommands={HelpCommand.class})
static public class Watch implements Runnable
{
@ParentCommand
ProductionC parent; // injected by picocli
@Option(names={"on", "-e", "--on", "--enable"}, description="Enables watching of given productions")
List<String> productionsToEnable;
@Option(names={"off", "-d", "--off", "--disable"}, description="Disables watching of given productions")
List<String> productionsToDisable;
@Override
public void run()
{ ... }
(Full code available here.)
Specifically, the productionsToEnable
does not seem to reset. The way the call is being made is part of a unit test:
@Test
public void testCanListTracedRules() throws Exception
{
loadRules();
agent.getInterpreter().eval("production watch --on b");
agent.getInterpreter().eval("production watch --on c");
final StringWriter result = new StringWriter();
agent.getPrinter().pushWriter(result);
agent.getInterpreter().eval("production watch");
agent.getPrinter().popWriter();
assertEquals("b\nc", result.toString());
}
(Full code available here.)
The string "c"
from the last call to production watch
is still present in productionsToEnable
when the production watch
command is called in the last eval
.
Note that the code links above are on the jsoar-command-performance
branch in case it's helpful to get a closer look.