diff options
Diffstat (limited to 'src/ri-engine/src/main/java/io/trygvis/rules/engine/cli')
-rw-r--r-- | src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java | 2 | ||||
-rw-r--r-- | src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java | 76 |
2 files changed, 42 insertions, 36 deletions
diff --git a/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java b/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java index 9e9d5f9..fa32e51 100644 --- a/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java +++ b/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java @@ -122,7 +122,7 @@ public class NinjaCommand implements Callable<Integer> { out.println(" output_state=--output-state %s".formatted(dbDir.resolve(output.name + ".yaml"))); if (!output.includes.isEmpty()) { var str = output.includes.stream() - .map(s -> "--output-include=" + s) + .map(s -> "--output-include='" + s + "'") .collect(Collectors.joining(" $\n ", "\n ", "")); out.println(" output_includes=$%s".formatted(str)); diff --git a/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java b/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java index 35f30cd..9b57e4f 100644 --- a/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java +++ b/src/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java @@ -39,44 +39,50 @@ public class RunCommand implements Callable<Integer> { agendaGroups = new String[]{"init", "generate"}; } + if (outputIncludes == null) { + outputIncludes = new String[0]; + } + 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; - } - ); + System.out.println("outputIncludes.length = " + outputIncludes.length); + engine.io.dump(outputState, engine.session.getFactHandles(), this::filter); } return 0; } + + private Boolean filter(Object o) { + if (outputIncludes.length == 0) { + return true; + } + + var name = o.getClass().getName(); + var simpleName = o.getClass().getSimpleName(); + var packageName = o.getClass().getPackageName(); + + 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.endsWith(i) || simpleName.endsWith(i) || packageName.endsWith(i); + } + } else if (i.endsWith("*")) { + i = i.substring(0, i.length() - 2); + ok = name.startsWith(i) || simpleName.startsWith(i) || packageName.startsWith(i); + } else { + ok = name.equals(i) || simpleName.equals(i) || packageName.equals(i); + } + + if (ok) { + return true; + } + } + + return false; + } } |