diff options
Diffstat (limited to 'module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java')
-rw-r--r-- | module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java deleted file mode 100644 index 35f30cd..0000000 --- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -package io.trygvis.rules.engine.cli; - -import io.trygvis.rules.engine.Engine; - -import java.io.File; -import java.util.concurrent.Callable; - -import static picocli.CommandLine.Command; -import static picocli.CommandLine.Option; - -@Command(name = "run") -public class RunCommand implements Callable<Integer> { - - @Option(names = {"-n", "--name"}) - public String name; - - @Option(names = {"-i", "--input"}) - public File[] input; - - @Option(names = {"--output-state"}) - public File outputState; - - @Option(names = {"--output-include"}, split = ",", arity = "1..*") - public String[] outputIncludes; - - @Option(names = {"--generated-output"}) - public File generatedOutput; - - @Option(names = {"--agenda-group"}) - public String[] agendaGroups; - - @Option(names = {"--module"}, split = ",", arity = "1..*") - public File[] module; - - @Override - public Integer call() throws Exception { - - if (agendaGroups == null || agendaGroups.length == 0) { - agendaGroups = new String[]{"init", "generate"}; - } - - try (var engine = new Engine(name, input, generatedOutput, agendaGroups, module)) { - engine.io.dump(outputState, engine.session.getFactHandles(), (Object o) -> - { - if (outputIncludes == null || outputIncludes.length == 0) { - return true; - } - - var name = o.getClass().getName(); - var simpleName = o.getClass().getSimpleName(); - - for (var i : outputIncludes) { - var ok = false; - if (i.startsWith("*")) { - i = i.substring(1); - - if (i.endsWith("*")) { - i = i.substring(1, i.length() - 2); - ok = name.contains(i); - } else { - ok = name.startsWith(i) || simpleName.startsWith(i); - } - } else if (i.endsWith("*")) { - i = i.substring(0, i.length() - 2); - ok = name.startsWith(i) || simpleName.startsWith(i); - } else { - ok = name.equals(i) || simpleName.equals(i); - } - - if (ok) { - return true; - } - } - - return false; - } - ); - } - - return 0; - } -} |